@@ -76,7 +76,7 @@ fflags="$fextra $cflags -frecursive -ffpe-summary=invalid,zero"
7676
7777# Set suffixed-ILP64 flags
7878if [ " $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"
@@ -90,8 +90,13 @@ interface_flags="$interface_flags SYMBOLPREFIX=scipy_ LIBNAMEPREFIX=scipy_ FIXED
9090# Build name for output library from gcc version and OpenBLAS commit.
9191GCC_TAG=" gcc_$( gcc -dumpversion | tr .- _) "
9292OPENBLAS_VERSION=$( git describe --tags --abbrev=8)
93+
94+ # Patch OpenBLAS build to resolve all symbols and avoid linking
95+ # with libquadmath
96+ patch -p1 < ../patches-windows/openblas-make-libs.patch
97+
9398# Build OpenBLAS
94- # Variable used in creating output libraries
99+ CFLAGS= " $CFLAGS -fvisibility=protected -fno-ident " \
95100make BINARY=$build_bits DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 \
96101 NUM_THREADS=24 NO_WARMUP=1 NO_AFFINITY=1 CONSISTENT_FPCSR=1 \
97102 BUILD_LAPACK_DEPRECATED=1 TARGET=PRESCOTT BUFFERSIZE=20\
@@ -100,8 +105,38 @@ make BINARY=$build_bits DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 \
100105 FCOMMON_OPT=" $fflags " \
101106 MAX_STACK_ALLOC=2048 \
102107 $interface_flags
108+
109+ # Make sure quadmath library is not statically linked in to the DLL by checking
110+ # the output.map generated by the linker when using `-Wl,-gc-sections -Wl,-s`
111+ # the map will have libname(o-filename) for each function pulled out of the
112+ # library libname
113+ # The file itself appears in the map, so look for "libquadmath.a(". Use '-A 3'
114+ # to show a bit of context if any symbols appear (which should not happen)
115+ set +e
116+ grep -A 2 " libquadmath.a(" exports/output.map
117+ case $? in
118+ 0)
119+ echo " link uses libquadmath.a when it should not"
120+ exit -1
121+ ;;
122+ 1)
123+ if [ -f exports/output.map ]; then
124+ echo " Good, verified no 'libquadmath' used when linking"
125+ else
126+ echo " error occurred"
127+ exit -1
128+ fi
129+ ;;
130+ * )
131+ echo " grep returned $? , error occurred"
132+ exit -1
133+ ;;
134+ esac
135+ set -e
136+
103137make PREFIX=$openblas_root /$build_bits $interface_flags install
104- DLL_BASENAME=libscipy_openblas${SYMBOLSUFFIX}${LIBNAMESUFFIX}
138+ DLL_BASENAME=libscipy_openblas${LIBNAMESUFFIX}
139+ cp -f * .dll.a $openblas_root /$build_bits /lib/${DLL_BASENAME} .dll.a
105140
106141# OpenBLAS does not build a symbol-suffixed static library on Windows:
107142# do it ourselves. On 32-bit builds, the objcopy.def names need a '_' prefix
@@ -143,16 +178,8 @@ else
143178 sed -e " s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_/" -i pkgconfig/scipy-openblas.pc
144179fi
145180popd
146- # Build template site.cfg for using this build
147- cat > ${build_bits} /site.cfg.template << EOF
148- [openblas${SYMBOLSUFFIX} ]
149- libraries = $DLL_BASENAME
150- library_dirs = {openblas_root}\\ ${build_bits} \\ lib
151- include_dirs = {openblas_root}\\ ${build_bits} \\ include
152- EOF
153-
154181ls $openblas_root /$build_bits /lib
155182
156- zip_name=" openblas${SYMBOLSUFFIX } -${OPENBLAS_VERSION} -${plat_tag} -${GCC_TAG} .zip"
183+ zip_name=" openblas${LIBNAMESUFFIX } -${OPENBLAS_VERSION} -${plat_tag} -${GCC_TAG} .zip"
157184zip -r $zip_name $build_bits
158185cp $zip_name ${builds_dir}
0 commit comments