summarylogtreecommitdiffstats
path: root/cblas.patch
diff options
context:
space:
mode:
Diffstat (limited to 'cblas.patch')
-rw-r--r--cblas.patch127
1 files changed, 127 insertions, 0 deletions
diff --git a/cblas.patch b/cblas.patch
new file mode 100644
index 000000000000..e742507ff3c5
--- /dev/null
+++ b/cblas.patch
@@ -0,0 +1,127 @@
+commit 0c442318196389d653ee21eba65d8c4f7beb72a0
+Author: Eli Schwartz <eschwartz@archlinux.org>
+Date: Fri Oct 5 15:52:17 2018 +0000
+
+ Use a dedicated cblas library, that may or may not be in fact the blas one.
+
+ Openblas can be built with statically compiled convenience copies of
+ cblas, but if not, then the system libcblas.so should be used.
+
+diff --git a/Make.inc b/Make.inc
+index b00a41b356..7bc6cd69e8 100644
+--- a/Make.inc
++++ b/Make.inc
+@@ -886,6 +886,7 @@ endif
+ ifeq ($(USE_SYSTEM_BLAS), 1)
+ ifeq ($(OS), Darwin)
+ USE_BLAS64 := 0
++USE_SYSTEM_CBLAS := 0
+ USE_SYSTEM_LAPACK := 0
+ LIBBLAS := -L$(build_libdir) -lgfortblas
+ LIBBLASNAME := libgfortblas
+@@ -898,12 +899,21 @@ LIBBLAS := -L$(build_shlibdir) -lopenblas
+ LIBBLASNAME := libopenblas
+ endif
+
+-# OpenBLAS builds LAPACK as part of its build.
++# OpenBLAS builds cblas/LAPACK as part of its build.
+ # We only need to build LAPACK if we are not using OpenBLAS.
+ ifeq ($(USE_SYSTEM_BLAS), 0)
++LIBCBLAS := $(LIBBLAS)
++LIBCBLASNAME := $(LIBBLASNAME)
+ LIBLAPACK := $(LIBBLAS)
+ LIBLAPACKNAME := $(LIBBLASNAME)
+ else
++ifeq ($(USE_SYSTEM_CBLAS), 1)
++LIBCBLAS ?= -lcblas
++LIBCBLASNAME ?= libcblas
++else
++LIBCBLAS := -L$(build_shlibdir) -lcblas $(LIBBLAS)
++LIBCBLASNAME := libcblas
++endif
+ ifeq ($(USE_SYSTEM_LAPACK), 1)
+ LIBLAPACK ?= -llapack
+ LIBLAPACKNAME ?= liblapack
+diff --git a/Makefile b/Makefile
+index 6063e79ae9..7df60b8170 100644
+--- a/Makefile
++++ b/Makefile
+@@ -254,6 +254,9 @@ endif
+ endif
+
+ JL_PRIVATE_LIBS-$(USE_SYSTEM_BLAS) += $(LIBBLASNAME)
++ifneq ($(LIBCBLASNAME),$(LIBBLASNAME))
++JL_PRIVATE_LIBS-$(USE_SYSTEM_CBLAS) += $(LIBCBLASNAME)
++endif
+ ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
+ JL_PRIVATE_LIBS-$(USE_SYSTEM_LAPACK) += $(LIBLAPACKNAME)
+ endif
+diff --git a/base/Makefile b/base/Makefile
+index 70e6da933d..8ecfa6902b 100644
+--- a/base/Makefile
++++ b/base/Makefile
+@@ -42,6 +42,7 @@ else
+ endif
+ @echo "const libm_name = \"$(LIBMNAME)\"" >> $@
+ @echo "const libblas_name = \"$(LIBBLASNAME)\"" >> $@
++ @echo "const libcblas_name = \"$(LIBCBLASNAME)\"" >> $@
+ @echo "const liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@
+ ifeq ($(USE_BLAS64), 1)
+ @echo "const USE_BLAS64 = true" >> $@
+@@ -175,6 +176,9 @@ endif
+ $(eval $(call symlink_system_library,libpcre2-8,PCRE))
+ $(eval $(call symlink_system_library,libdSFMT,DSFMT))
+ $(eval $(call symlink_system_library,$(LIBBLASNAME),BLAS))
++ifneq ($(LIBCBLASNAME),$(LIBBLASNAME))
++$(eval $(call symlink_system_library,$(LIBCBLASNAME),CBLAS))
++endif
+ ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
+ $(eval $(call symlink_system_library,$(LIBLAPACKNAME),LAPACK))
+ endif
+diff --git a/stdlib/LinearAlgebra/src/blas.jl b/stdlib/LinearAlgebra/src/blas.jl
+index fee8c9e74d..8c76d1acbf 100644
+--- a/stdlib/LinearAlgebra/src/blas.jl
++++ b/stdlib/LinearAlgebra/src/blas.jl
+@@ -62,6 +62,7 @@ export
+
+
+ const libblas = Base.libblas_name
++const libcblas = Base.libcblas_name
+ const liblapack = Base.liblapack_name
+
+ import LinearAlgebra
+@@ -102,6 +103,16 @@ else
+ end
+ end
+
++if libcblas == libblas
++ macro cblasfunc(x)
++ return @blasfunc(x)
++ end
++else
++ macro cblasfunc(x)
++ return Expr(:quote, x)
++ end
++end
++
+ openblas_get_config() = strip(unsafe_string(ccall((@blasfunc(openblas_get_config), Base.libblas_name), Ptr{UInt8}, () )))
+
+ """
+@@ -301,7 +312,7 @@ for (fname, elty) in ((:cblas_zdotc_sub,:ComplexF64),
+ # DOUBLE PRECISION DX(*),DY(*)
+ function dotc(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer)
+ result = Ref{$elty}()
+- ccall((@blasfunc($fname), libblas), Cvoid,
++ ccall((@cblasfunc($fname), libcblas), Cvoid,
+ (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
+ n, DX, incx, DY, incy, result)
+ result[]
+@@ -319,7 +330,7 @@ for (fname, elty) in ((:cblas_zdotu_sub,:ComplexF64),
+ # DOUBLE PRECISION DX(*),DY(*)
+ function dotu(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer)
+ result = Ref{$elty}()
+- ccall((@blasfunc($fname), libblas), Cvoid,
++ ccall((@cblasfunc($fname), libcblas), Cvoid,
+ (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
+ n, DX, incx, DY, incy, result)
+ result[]