From 10a6e3c34b5efffb6c1f993e64ebaf2d72a0bd1f Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Sat, 25 Jun 2022 13:20:14 +0100 Subject: [PATCH] WIP: patch OpenBLAS build for quadmath symbols Apply Carl's patch to OpenBLAS export build of library, to remove libquatmath symbol. See: https://github.com/MacPython/openblas-libs/pull/82#issuecomment-1161869998 --- patches/openblas-make-libs.patch | 27 +++++++++++++++++++++++++++ tools/build_openblas.sh | 5 +++++ 2 files changed, 32 insertions(+) create mode 100644 patches/openblas-make-libs.patch diff --git a/patches/openblas-make-libs.patch b/patches/openblas-make-libs.patch new file mode 100644 index 0000000..6b0526d --- /dev/null +++ b/patches/openblas-make-libs.patch @@ -0,0 +1,27 @@ +diff --git a/exports/Makefile b/exports/Makefile +index d8173534..4e2e0d7b 100644 +--- a/exports/Makefile ++++ b/exports/Makefile +@@ -119,11 +119,21 @@ dll : ../$(LIBDLLNAME) + # in their import table. By instead using a stable name it is possible to + # upgrade between library versions, without needing to re-link an application. + # For more details see: https://github.com/xianyi/OpenBLAS/issues/127. ++ifeq ($(DEBUG), 1) + ../$(LIBDLLNAME) : ../$(LIBNAME) $(LIBPREFIX).def dllinit.$(SUFFIX) + $(RANLIB) ../$(LIBNAME) + $(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \ +- -shared -o ../$(LIBDLLNAME) -Wl,--out-implib,../$(IMPLIBNAME) \ ++ -shared -o ../$(LIBDLLNAME) -Wl,--defsym,quadmath_snprintf=snprintf \ + -Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB) ++ dlltool -D $(LIBDLLNAME) -d $(LIBPREFIX).def -l ../$(LIBDLLNAME).a ++else ++../$(LIBDLLNAME) : ../$(LIBNAME) $(LIBPREFIX).def dllinit.$(SUFFIX) ++ $(RANLIB) ../$(LIBNAME) ++ $(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \ ++ -shared -o ../$(LIBDLLNAME) -Wl,--defsym,quadmath_snprintf=snprintf -Wl,-gc-sections -Wl,-s \ ++ -Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB) ++ dlltool -D $(LIBDLLNAME) -d $(LIBPREFIX).def -l ../$(LIBDLLNAME).a ++endif + + $(LIBPREFIX).def : $(GENSYM) + ./$(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) diff --git a/tools/build_openblas.sh b/tools/build_openblas.sh index 59f72f8..c73632f 100644 --- a/tools/build_openblas.sh +++ b/tools/build_openblas.sh @@ -63,6 +63,11 @@ fi # Build name for output library from gcc version and OpenBLAS commit. GCC_TAG="gcc_$(gcc -dumpversion | tr .- _)" OPENBLAS_VERSION=$(git describe --tags) +# Patch OpenBLAS to exclude stray GFortran symbol. +# Replacement snprintf symbol only present for UCRTC 64-bit build. +if [ "$BUILD_BITS" == 64 ]; then + patch -p1 < ../patches/openblas-make-libs.patch +fi # Build OpenBLAS # Variable used in creating output libraries export LIBNAMESUFFIX=${OPENBLAS_VERSION}-${GCC_TAG}