Skip to content

Commit

Permalink
WIP: patch OpenBLAS build for quadmath symbols
Browse files Browse the repository at this point in the history
Apply Carl's patch to OpenBLAS export build of library, to remove
libquatmath symbol.

See:
#82 (comment)
  • Loading branch information
matthew-brett committed Jun 25, 2022
1 parent b9aefee commit 10a6e3c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions patches/openblas-make-libs.patch
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions tools/build_openblas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 10a6e3c

Please sign in to comment.