Skip to content

Commit 85180c0

Browse files
committed
Patch openblas to add 64_ suffix when using 64 bit ints
1 parent 636f481 commit 85180c0

File tree

2 files changed

+339
-3
lines changed

2 files changed

+339
-3
lines changed

deps/Makefile

+23-3
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,10 @@ endif
829829

830830
# 64-bit BLAS interface
831831
ifeq ($(USE_BLAS64), 1)
832-
OPENBLAS_BUILD_OPTS += INTERFACE64=1
832+
OPENBLAS_BUILD_OPTS += INTERFACE64=1 SYMBOLSUFFIX="64_"
833+
ifeq ($(OS),Darwin)
834+
OPENBLAS_BUILD_OPTS += OBJCONV=$(JULIAHOME)/deps/objconv/objconv
835+
endif
833836
endif
834837

835838
# Decide whether to build for 32-bit or 64-bit arch
@@ -864,6 +867,7 @@ endif
864867
mkdir -p openblas-$(OPENBLAS_VER) && \
865868
$(TAR) -C openblas-$(OPENBLAS_VER) --strip-components 1 -xf $<
866869
perl -i -ple 's/^\s*(EXTRALIB\s*\+=\s*-lSystemStubs)\s*$$/# $$1/g' openblas-$(OPENBLAS_VER)/Makefile.system
870+
cd openblas-$(OPENBLAS_VER) && patch -p1 < ../openblas-symbol-rename.patch
867871
echo 1 > $@
868872
$(OPENBLAS_OBJ_SOURCE): openblas-$(OPENBLAS_VER)/config.status
869873
$(MAKE) -C openblas-$(OPENBLAS_VER) $(OPENBLAS_BUILD_OPTS) || (echo "*** Clean the OpenBLAS build with 'make -C deps clean-openblas'. Rebuild with 'make OPENBLAS_USE_THREAD=0 if OpenBLAS had trouble linking libpthread.so, and with 'make OPENBLAS_TARGET_ARCH=NEHALEM' if there were errors building SandyBridge support. Both these options can also be used simultaneously. ***" && false)
@@ -1032,6 +1036,16 @@ ifeq ($(USEIFC),1)
10321036
ARPACK_FFLAGS += -i8
10331037
else
10341038
ARPACK_FFLAGS += -fdefault-integer-8
1039+
ifeq ($(USE_SYSTEM_BLAS), 0)
1040+
ifneq ($(USE_INTEL_MKL), 1)
1041+
ARPACK_OPENBLASFCNS1 = axpy copy gemv geqr2 lacpy lahqr lanhs larnv lartg lascl laset scal trevc trmm trsen
1042+
ARPACK_OPENBLASFCNS2 = dot ger labad laev2 lamch lanst lanv2 lapy2 larf larfg lasr nrm2 orm2r rot steqr swap
1043+
ARPACK_OPENBLASFCNS3 = dotc geru unm2r
1044+
ARPACK_FFLAGS += $(foreach fcn, $(ARPACK_OPENBLASFCNS1) $(ARPACK_OPENBLASFCNS2), -Ds$(fcn)=s$(fcn)_64 -Dd$(fcn)=d$(fcn)_64)
1045+
ARPACK_FFLAGS += $(foreach fcn, $(ARPACK_OPENBLASFCNS1) $(ARPACK_OPENBLASFCNS3), -Dc$(fcn)=c$(fcn)_64 -Dz$(fcn)=z$(fcn)_64)
1046+
ARPACK_FFLAGS += -Dscnrm2=scnrm2_64 -Ddznrm2=dznrm2_64 -Dcsscal=csscal_64 -Dzdscal=zdscal_64
1047+
endif
1048+
endif
10351049
endif
10361050
endif
10371051

@@ -1287,8 +1301,14 @@ SUITESPARSE_OBJ_SOURCE = SuiteSparse-$(SUITESPARSE_VER)/UMFPACK/Lib/libumfpack.a
12871301
SUITESPARSE_OBJ_TARGET = $(build_shlibdir)/libspqr.$(SHLIB_EXT)
12881302

12891303
ifeq ($(USE_BLAS64), 1)
1290-
UMFPACK_CONFIG = -DLONGBLAS='long long'
1291-
CHOLMOD_CONFIG = -DLONGBLAS='long long'
1304+
UMFPACK_CONFIG = -DLONGBLAS='long long'
1305+
CHOLMOD_CONFIG = -DLONGBLAS='long long'
1306+
ifeq ($(USE_SYSTEM_BLAS), 0)
1307+
ifneq ($(USE_INTEL_MKL), 1)
1308+
UMFPACK_CONFIG += -DSUN64
1309+
CHOLMOD_CONFIG += -DSUN64
1310+
endif
1311+
endif
12921312
endif
12931313

12941314
SUITE_SPARSE_LIB = -lm

deps/openblas-symbol-rename.patch

+316
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
diff --git a/Makefile.system b/Makefile.system
2+
index d2ff741..ec6339d 100644
3+
--- a/Makefile.system
4+
+++ b/Makefile.system
5+
@@ -186,6 +186,8 @@ LD = $(CROSS_SUFFIX)ld
6+
RANLIB = $(CROSS_SUFFIX)ranlib
7+
NM = $(CROSS_SUFFIX)nm
8+
DLLWRAP = $(CROSS_SUFFIX)dllwrap
9+
+OBJCOPY = $(CROSS_SUFFIX)objcopy
10+
+OBJCONV = $(CROSS_SUFFIX)objconv
11+
12+
#
13+
# OS dependent settings
14+
@@ -845,6 +847,14 @@ else
15+
LIBPREFIX = libopenblas_$(LIBNAMESUFFIX)
16+
endif
17+
18+
+ifndef SYMBOLPREFIX
19+
+SYMBOLPREFIX =
20+
+endif
21+
+
22+
+ifndef SYMBOLSUFFIX
23+
+SYMBOLSUFFIX =
24+
+endif
25+
+
26+
KERNELDIR = $(TOPDIR)/kernel/$(ARCH)
27+
28+
include $(TOPDIR)/Makefile.$(ARCH)
29+
diff --git a/exports/Makefile b/exports/Makefile
30+
index c798bc7..9ed5a0f 100644
31+
--- a/exports/Makefile
32+
+++ b/exports/Makefile
33+
@@ -88,12 +88,17 @@ dll : ../$(LIBDLLNAME)
34+
-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB)
35+
36+
libopenblas.def : gensymbol
37+
- perl ./gensymbol win2k $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) > $(@F)
38+
+ perl ./gensymbol win2k $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > $(@F)
39+
40+
libgoto_hpl.def : gensymbol
41+
- perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) > $(@F)
42+
+ perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > $(@F)
43+
44+
+ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
45+
$(LIBDYNNAME) : ../$(LIBNAME) osx.def
46+
+else
47+
+$(LIBDYNNAME) : ../$(LIBNAME) osx.def objconv.def
48+
+ $(OBJCONV) @objconv.def ../$(LIBNAME)
49+
+endif
50+
$(FC) $(FFLAGS) -all_load -headerpad_max_install_names -install_name $(CURDIR)/../$(LIBDYNNAME) -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB)
51+
52+
dllinit.$(SUFFIX) : dllinit.c
53+
@@ -103,7 +108,12 @@ ifeq ($(OSNAME), Linux)
54+
55+
so : ../$(LIBSONAME)
56+
57+
+ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
58+
../$(LIBSONAME) : ../$(LIBNAME) linktest.c
59+
+else
60+
+../$(LIBSONAME) : ../$(LIBNAME) linktest.c objcopy.def
61+
+ $(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME)
62+
+endif
63+
ifneq ($(C_COMPILER), LSB)
64+
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
65+
-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive \
66+
@@ -125,7 +135,12 @@ ifeq ($(OSNAME), $(filter $(OSNAME),FreeBSD NetBSD))
67+
68+
so : ../$(LIBSONAME)
69+
70+
+ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
71+
../$(LIBSONAME) : ../$(LIBNAME) linktest.c
72+
+else
73+
+../$(LIBSONAME) : ../$(LIBNAME) linktest.c objcopy.def
74+
+ $(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME)
75+
+endif
76+
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
77+
-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive \
78+
$(FEXTRALIB) $(EXTRALIB)
79+
@@ -178,17 +193,23 @@ static : ../$(LIBNAME)
80+
rm -f goto.$(SUFFIX)
81+
82+
osx.def : gensymbol ../Makefile.system ../getarch.c
83+
- perl ./gensymbol osx $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) > $(@F)
84+
+ perl ./gensymbol osx $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > $(@F)
85+
86+
aix.def : gensymbol ../Makefile.system ../getarch.c
87+
- perl ./gensymbol aix $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) > $(@F)
88+
+ perl ./gensymbol aix $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > $(@F)
89+
+
90+
+objcopy.def : gensymbol ../Makefile.system ../getarch.c
91+
+ perl ./gensymbol objcopy $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > $(@F)
92+
+
93+
+objconv.def : gensymbol ../Makefile.system ../getarch.c
94+
+ perl ./gensymbol objconv $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > $(@F)
95+
96+
test : linktest.c
97+
$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) -lm && echo OK.
98+
rm -f linktest
99+
100+
linktest.c : gensymbol ../Makefile.system ../getarch.c
101+
- perl ./gensymbol linktest $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) > linktest.c
102+
+ perl ./gensymbol linktest $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" > linktest.c
103+
104+
clean ::
105+
@rm -f *.def *.dylib __.SYMDEF*
106+
diff --git a/exports/gensymbol b/exports/gensymbol
107+
index bcea836..8bd2f17 100644
108+
--- a/exports/gensymbol
109+
+++ b/exports/gensymbol
110+
@@ -2784,22 +2784,26 @@ $bu = $ARGV[2];
111+
112+
$bu = "" if (($bu eq "0") || ($bu eq "1"));
113+
114+
+$symbolprefix = $ARGV[9];
115+
+
116+
+$symbolsuffix = $ARGV[10];
117+
+
118+
if ($ARGV[0] eq "osx"){
119+
120+
@underscore_objs = (@underscore_objs, @misc_common_objs);
121+
@no_underscore_objs = (@no_underscore_objs, @misc_common_objs);
122+
123+
foreach $objs (@underscore_objs) {
124+
- print "_", $objs, $bu, "\n";
125+
+ print "_", $symbolprefix, $objs, $bu, $symbolsuffix, "\n";
126+
}
127+
128+
foreach $objs (@need_2underscore_objs) {
129+
- print "_", $objs, $bu, $bu, "\n";
130+
+ print "_", $symbolprefix, $objs, $bu, $bu, $symbolsuffix, "\n";
131+
}
132+
133+
# if ($ARGV[4] == 0) {
134+
foreach $objs (@no_underscore_objs) {
135+
- print "_", $objs, "\n";
136+
+ print "_", $symbolprefix, $objs, $symbolsuffix, "\n";
137+
}
138+
# }
139+
exit(0);
140+
@@ -2811,16 +2815,58 @@ if ($ARGV[0] eq "aix"){
141+
@no_underscore_objs = (@no_underscore_objs, @misc_common_objs);
142+
143+
foreach $objs (@underscore_objs) {
144+
- print $objs, $bu, "\n";
145+
+ print $symbolprefix, $objs, $bu, $symbolsuffix, "\n";
146+
+ }
147+
+
148+
+ foreach $objs (@need_2underscore_objs) {
149+
+ print $symbolprefix, $objs, $bu, $bu, $symbolsuffix, "\n";
150+
+ }
151+
+
152+
+# if ($ARGV[4] == 0) {
153+
+ foreach $objs (@no_underscore_objs) {
154+
+ print $symbolprefix, $objs, $symbolsuffix, "\n";
155+
+ }
156+
+# }
157+
+ exit(0);
158+
+}
159+
+
160+
+if ($ARGV[0] eq "objcopy"){
161+
+
162+
+ @underscore_objs = (@underscore_objs, @misc_common_objs);
163+
+ @no_underscore_objs = (@no_underscore_objs, @misc_common_objs);
164+
+
165+
+ foreach $objs (@underscore_objs) {
166+
+ print $objs, $bu, " ", $symbolprefix, $objs, $bu, $symbolsuffix, "\n";
167+
+ }
168+
+
169+
+ foreach $objs (@need_2underscore_objs) {
170+
+ print $objs, $bu, $bu, " ", $symbolprefix, $objs, $bu, $bu, $symbolsuffix, "\n";
171+
+ }
172+
+
173+
+# if ($ARGV[4] == 0) {
174+
+ foreach $objs (@no_underscore_objs) {
175+
+ print $objs, " ", $symbolprefix, $objs, $symbolsuffix, "\n";
176+
+ }
177+
+# }
178+
+ exit(0);
179+
+}
180+
+
181+
+if ($ARGV[0] eq "objconv"){
182+
+
183+
+ @underscore_objs = (@underscore_objs, @misc_common_objs);
184+
+ @no_underscore_objs = (@no_underscore_objs, @misc_common_objs);
185+
+
186+
+ foreach $objs (@underscore_objs) {
187+
+ print "-nr:_", $objs, $bu, ":_", $symbolprefix, $objs, $bu, $symbolsuffix, "\n";
188+
}
189+
190+
foreach $objs (@need_2underscore_objs) {
191+
- print $objs, $bu, $bu, "\n";
192+
+ print "-nr:_", $objs, $bu, $bu, ":_", $symbolprefix, $objs, $bu, $bu, $symbolsuffix, "\n";
193+
}
194+
195+
# if ($ARGV[4] == 0) {
196+
foreach $objs (@no_underscore_objs) {
197+
- print $objs, "\n";
198+
+ print "-nr:_", $objs, ":_", $symbolprefix, $objs, $symbolsuffix, "\n";
199+
}
200+
# }
201+
exit(0);
202+
@@ -2835,22 +2881,22 @@ if ($ARGV[0] eq "win2k"){
203+
foreach $objs (@underscore_objs) {
204+
$uppercase = $objs;
205+
$uppercase =~ tr/[a-z]/[A-Z]/;
206+
- print "\t$objs=$objs","_ \@", $count, "\n";
207+
+ print "\t",$symbolprefix, $objs, $symbolsuffix, "=$objs","_ \@", $count, "\n";
208+
$count ++;
209+
- print "\t",$objs, "_=$objs","_ \@", $count, "\n";
210+
+ print "\t",$symbolprefix, $objs, "_", $symbolsuffix, "=$objs","_ \@", $count, "\n";
211+
$count ++;
212+
- print "\t$uppercase=$objs", "_ \@", $count, "\n";
213+
+ print "\t",$symbolprefix, $uppercase, $symbolsuffix, "=$objs", "_ \@", $count, "\n";
214+
$count ++;
215+
}
216+
217+
foreach $objs (@need_2underscore_objs) {
218+
$uppercase = $objs;
219+
$uppercase =~ tr/[a-z]/[A-Z]/;
220+
- print "\t$objs=$objs","__ \@", $count, "\n";
221+
+ print "\t",$symbolprefix, $objs, $symbolsuffix, "=$objs","__ \@", $count, "\n";
222+
$count ++;
223+
- print "\t",$objs, "__=$objs","__ \@", $count, "\n";
224+
+ print "\t",$symbolprefix, $objs, "__", $symbolsuffix, "=$objs","__ \@", $count, "\n";
225+
$count ++;
226+
- print "\t$uppercase=$objs", "__ \@", $count, "\n";
227+
+ print "\t",$symbolprefix, $uppercase, $symbolsuffix, "=$objs", "__ \@", $count, "\n";
228+
$count ++;
229+
}
230+
231+
@@ -2859,15 +2905,15 @@ if ($ARGV[0] eq "win2k"){
232+
233+
$uppercase = $objs;
234+
$uppercase =~ tr/[a-z]/[A-Z]/;
235+
- print "\t",$objs, "_=$objs","_ \@", $count, "\n";
236+
+ print "\t",$symbolprefix, $objs, "_", $symbolsuffix, "=$objs","_ \@", $count, "\n";
237+
$count ++;
238+
- print "\t$uppercase=$objs", "_ \@", $count, "\n";
239+
+ print "\t",$symbolprefix, $uppercase, $symbolsuffix, "=$objs", "_ \@", $count, "\n";
240+
$count ++;
241+
}
242+
243+
244+
foreach $objs (@no_underscore_objs) {
245+
- print "\t",$objs,"=$objs"," \@", $count, "\n";
246+
+ print "\t",$symbolprefix,$objs,$symbolsuffix,"=$objs"," \@", $count, "\n";
247+
$count ++;
248+
}
249+
250+
@@ -2880,11 +2926,11 @@ if ($ARGV[0] eq "win2khpl"){
251+
foreach $objs (@hplobjs) {
252+
$uppercase = $objs;
253+
$uppercase =~ tr/[a-z]/[A-Z]/;
254+
- print "\t$objs=$objs","_ \@", $count, "\n";
255+
+ print "\t",$symbolprefix, $objs, $symbolsuffix, "=$objs","_ \@", $count, "\n";
256+
$count ++;
257+
- print "\t",$objs, "_=$objs","_ \@", $count, "\n";
258+
+ print "\t",$symbolprefix, $objs, "_", $symbolsuffix, "=$objs","_ \@", $count, "\n";
259+
$count ++;
260+
- print "\t$uppercase=$objs", "_ \@", $count, "\n";
261+
+ print "\t",$symbolprefix, $uppercase, $symbolsuffix, "=$objs", "_ \@", $count, "\n";
262+
$count ++;
263+
}
264+
265+
@@ -2905,24 +2951,24 @@ if ($ARGV[0] eq "microsoft"){
266+
foreach $objs (@underscore_objs) {
267+
$uppercase = $objs;
268+
$uppercase =~ tr/[a-z]/[A-Z]/;
269+
- print "\t$objs = $objs","_\n";
270+
+ print "\t",$symbolprefix, $objs, $symbolsuffix, " = $objs","_\n";
271+
$count ++;
272+
- print "\t$objs\_ = $objs","_\n";
273+
+ print "\t",$symbolprefix, $objs, "\_", $symbolsuffix, " = $objs","_\n";
274+
$count ++;
275+
- print "\t$uppercase = $objs","_\n";
276+
+ print "\t",$symbolprefix, $uppercase, $symbolsuffix, " = $objs","_\n";
277+
$count ++;
278+
- print "\t$uppercase\_ = $objs","_\n";
279+
+ print "\t",$symbolprefix, $uppercase, "\_", $symbolsuffix, " = $objs","_\n";
280+
$count ++;
281+
}
282+
283+
foreach $objs (@need_2underscore_objs) {
284+
$uppercase = $objs;
285+
$uppercase =~ tr/[a-z]/[A-Z]/;
286+
- print "\t$objs=$objs","__ \@", $count, "\n";
287+
+ print "\t",$symbolprefix, $objs, $symbolsuffix, "=$objs","__ \@", $count, "\n";
288+
$count ++;
289+
- print "\t",$objs, "__=$objs","__ \@", $count, "\n";
290+
+ print "\t",$symbolprefix, $objs, "__", $symbolsuffix, "=$objs","__ \@", $count, "\n";
291+
$count ++;
292+
- print "\t$uppercase=$objs", "__ \@", $count, "\n";
293+
+ print "\t",$symbolprefix, $uppercase, $symbolsuffix, "=$objs", "__ \@", $count, "\n";
294+
$count ++;
295+
}
296+
297+
@@ -2936,16 +2982,16 @@ if ($ARGV[0] eq "linktest"){
298+
299+
print "int main(void){\n";
300+
foreach $objs (@underscore_objs) {
301+
- print $objs, $bu, "();\n" if $objs ne "xerbla";
302+
+ print $symbolprefix, $objs, $bu, $symbolsuffix, "();\n" if $objs ne "xerbla";
303+
}
304+
305+
foreach $objs (@need_2underscore_objs) {
306+
- print $objs, $bu, $bu, "();\n";
307+
+ print $symbolprefix, $objs, $bu, $bu, $symbolsuffix, "();\n";
308+
}
309+
310+
# if ($ARGV[4] == 0) {
311+
foreach $objs (@no_underscore_objs) {
312+
- print $objs, "();\n";
313+
+ print $symbolprefix, $objs, $symbolsuffix, "();\n";
314+
}
315+
# }
316+

0 commit comments

Comments
 (0)