Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 261b95e

Browse files
committed
redo patch, ensure libquadmath is not used in static link
1 parent 12a2b7b commit 261b95e

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed
Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
diff --git a/exports/Makefile b/exports/Makefile
2-
index d8173534..4e2e0d7b 100644
2+
index 668a4866e..956b51bf4 100644
33
--- a/exports/Makefile
44
+++ b/exports/Makefile
5-
@@ -123,11 +123,21 @@ dll : ../$(LIBDLLNAME)
6-
# in their import table. By instead using a stable name it is possible to
7-
# upgrade between library versions, without needing to re-link an application.
8-
# For more details see: https://github.com/xianyi/OpenBLAS/issues/127.
9-
+ifeq ($(DEBUG), 1)
5+
@@ -126,8 +126,9 @@ dll : ../$(LIBDLLNAME)
106
../$(LIBDLLNAME) : ../$(LIBNAME) $(LIBPREFIX).def dllinit.$(SUFFIX)
11-
$(RANLIB) ../$(LIBNAME)
12-
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \
13-
- -shared -o ../$(LIBDLLNAME) -Wl,--out-implib,../$(IMPLIBNAME) \
14-
+ -shared -o ../$(LIBDLLNAME) -Wl,--defsym,quadmath_snprintf=snprintf \
15-
-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB)
16-
+ dlltool -D $(LIBDLLNAME) -d $(LIBPREFIX).def -l ../$(LIBDLLNAME).a
17-
+else
18-
+../$(LIBDLLNAME) : ../$(LIBNAME) $(LIBPREFIX).def dllinit.$(SUFFIX)
19-
+ $(RANLIB) ../$(LIBNAME)
20-
+ $(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \
21-
+ -shared -o ../$(LIBDLLNAME) -Wl,--defsym,quadmath_snprintf=snprintf -Wl,-gc-sections -Wl,-s \
22-
+ -Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB)
23-
+ dlltool -D $(LIBDLLNAME) -d $(LIBPREFIX).def -l ../$(LIBDLLNAME).a
24-
+endif
25-
7+
$(RANLIB) ../$(LIBNAME)
8+
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \
9+
- -shared -o ../$(LIBDLLNAME) -Wl,--out-implib,../$(IMPLIBNAME) \
10+
+ -shared -o ../$(LIBDLLNAME) -Wl,-gc-sections -Wl,-s -Wl,-Map,output.map \
11+
-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB)
12+
+ dlltool -D $(LIBDLLNAME) -d $(LIBPREFIX).def -l ../$(LIBDLLNAME).a
13+
2614
$(LIBPREFIX).def : $(GENSYM)
27-
./$(GENSYM) win2k $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
15+
./$(GENSYM) win2k $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)

tools/build_openblas.sh

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ git submodule update --init --recursive
4949

5050

5151
# Get / clean code
52-
git fetch origin
53-
if [ -n "$OPENBLAS_COMMIT" ]; then
54-
git checkout $OPENBLAS_COMMIT
55-
fi
56-
git clean -fxd
57-
git reset --hard
52+
# git fetch origin
53+
# if [ -n "$OPENBLAS_COMMIT" ]; then
54+
# git checkout $OPENBLAS_COMMIT
55+
# fi
56+
# git clean -fxd
57+
# git reset --hard
5858
rm -rf $openblas_root/$build_bits
5959

6060
# Set architecture flags
@@ -76,7 +76,7 @@ fflags="$fextra $cflags -frecursive -ffpe-summary=invalid,zero"
7676

7777
# Set suffixed-ILP64 flags
7878
if [ "$if_bits" == "64" ]; then
79-
SYMBOLSUFFIX="64_"
79+
LIBNAMESUFFIX="64_"
8080
interface_flags="INTERFACE64=1 SYMBOLSUFFIX=64_ LIBNAMESUFFIX=64_"
8181
# We override FCOMMON_OPT, so we need to set default integer manually
8282
fflags="$fflags -fdefault-integer-8"
@@ -92,9 +92,9 @@ GCC_TAG="gcc_$(gcc -dumpversion | tr .- _)"
9292
OPENBLAS_VERSION=$(git describe --tags --abbrev=8)
9393
# Patch OpenBLAS to exclude stray GFortran symbol.
9494
# Replacement snprintf symbol only present for UCRTC 64-bit build.
95-
if [ "$BUILD_BITS" == 64 ]; then
96-
patch -p1 < ../patches-windows/openblas-make-libs.patch
97-
fi
95+
# if [ "$BUILD_BITS" == 64 ]; then
96+
# patch -p1 < ../patches-windows/openblas-make-libs.patch
97+
# fi
9898
# Build OpenBLAS
9999
# Variable used in creating output libraries
100100
make BINARY=$build_bits DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 \
@@ -132,6 +132,26 @@ objcopy --redefine-syms exports/objcopy.def "${static_libname}" "${static_libnam
132132
cp -f "${static_libname}.renamed" "$openblas_root/$build_bits/lib/${static_libname}"
133133
cp -f "${static_libname}.renamed" "$openblas_root/$build_bits/lib/${DLL_BASENAME}.a"
134134

135+
# Make sure quadmath library is not statically linked in to the DLL by checking
136+
# the output.map generated by the linker when using `-Wl,-gc-sections -Wl,-s`
137+
# the map will have libname(o-filename) for each function pulled out of the
138+
# library
139+
# The file itself appears in the map
140+
grep -A 3 "libquadmath.a(" output.map
141+
case $? in
142+
0)
143+
echo "link uses libquadmath.a when it should not"
144+
exit -1
145+
;;
146+
2)
147+
echo "could not find 'output.map' to verify linking avoids libquadmath.a"
148+
exit -1
149+
;;
150+
1)
151+
echo "verified no 'libquadmath' used when linking"
152+
;;
153+
esac
154+
135155
cd $openblas_root
136156
# Copy library link file for custom name
137157
pushd $build_bits/lib
@@ -154,16 +174,8 @@ else
154174
sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_/" -i pkgconfig/scipy-openblas.pc
155175
fi
156176
popd
157-
# Build template site.cfg for using this build
158-
cat > ${build_bits}/site.cfg.template << EOF
159-
[openblas${SYMBOLSUFFIX}]
160-
libraries = $DLL_BASENAME
161-
library_dirs = {openblas_root}\\${build_bits}\\lib
162-
include_dirs = {openblas_root}\\${build_bits}\\include
163-
EOF
164-
165177
ls $openblas_root/$build_bits/lib
166178

167-
zip_name="openblas${SYMBOLSUFFIX}-${OPENBLAS_VERSION}-${plat_tag}-${GCC_TAG}.zip"
179+
zip_name="openblas${LIBNAMESUFFIX}-${OPENBLAS_VERSION}-${plat_tag}-${GCC_TAG}.zip"
168180
zip -r $zip_name $build_bits
169181
cp $zip_name ${builds_dir}

0 commit comments

Comments
 (0)