|
| 1 | +diff --git a/Makefile.system b/Makefile.system |
| 2 | +index e8e732e9c..9b05ed213 100644 |
| 3 | +--- a/Makefile.system |
| 4 | ++++ b/Makefile.system |
| 5 | +@@ -1207,15 +1207,17 @@ FCOMMON_OPT += -Wall |
| 6 | + FCOMMON_OPT += -frecursive |
| 7 | + # work around ABI problem with passing single-character arguments |
| 8 | + FCOMMON_OPT += -fno-optimize-sibling-calls |
| 9 | +-#Don't include -lgfortran, when NO_LAPACK=1 or lsbcc |
| 10 | ++#Don't include -lgfortran, when NO_LAPACK=1 or lsbcc or NO_LIBGFORTRAN=1 |
| 11 | + ifneq ($(NOFORTRAN), 1) |
| 12 | + ifneq ($(NOFORTRAN), 2) |
| 13 | + ifneq ($(NO_LAPACK), 1) |
| 14 | ++ifneq ($(NO_LIBGFORTRAN), 1) |
| 15 | + EXTRALIB += -lgfortran |
| 16 | + endif |
| 17 | + endif |
| 18 | + endif |
| 19 | + endif |
| 20 | ++endif |
| 21 | + ifdef NO_BINARY_MODE |
| 22 | + ifeq ($(ARCH), $(filter $(ARCH),mips64)) |
| 23 | + ifdef BINARY64 |
| 24 | +@@ -1917,6 +1919,43 @@ export CROSS |
| 25 | + export CROSS_SUFFIX |
| 26 | + export NOFORTRAN |
| 27 | + export C_LAPACK |
| 28 | ++# NO_LIBGFORTRAN=1 builds a library with no runtime dependency on the Fortran |
| 29 | ++# runtime. LIBGFORTRAN_COMPAT must point at an archive supplying the few |
| 30 | ++# libgfortran entry points the Fortran LAPACK sources reference; the link |
| 31 | ++# fails loudly if it does not cover them all. libquadmath goes away along |
| 32 | ++# with libgfortran, being only ever a dependency of libgfortran itself. |
| 33 | ++# |
| 34 | ++# The archive is kept out of EXTRALIB on purpose: EXTRALIB is what |
| 35 | ++# Makefile.install writes into the installed .pc file, and a build-time |
| 36 | ++# absolute path has no business being there. It goes into |
| 37 | ++# LIBGFORTRAN_COMPAT_LINK, which the shared-library link rules add directly, |
| 38 | ++# and into FEXTRALIB, which is what the macOS dylib rule uses. |
| 39 | ++# |
| 40 | ++# Kept here, at the end and at top level, so it sees the final value of |
| 41 | ++# FEXTRALIB whatever the USE_OPENMP and compiler conditionals above did. |
| 42 | ++ifeq ($(NO_LIBGFORTRAN), 1) |
| 43 | ++FEXTRALIB := $(filter-out -lgfortran -lquadmath,$(FEXTRALIB)) |
| 44 | ++ifneq ($(LIBGFORTRAN_COMPAT), ) |
| 45 | ++ifeq ($(OSNAME), Darwin) |
| 46 | ++# ld64 has no --exclude-libs and needs none: the dylib link passes |
| 47 | ++# -Wl,-exported_symbols_list,osx.def, which holds only the BLAS and LAPACK |
| 48 | ++# names, so whatever the compat archive brings in is unexported already. |
| 49 | ++# -dead_strip_dylibs is what macOS needs instead. The dylib is linked by the |
| 50 | ++# gfortran driver, which appends -lgfortran itself whatever FEXTRALIB says; |
| 51 | ++# this drops the load command of a dylib no symbol resolves to, taking |
| 52 | ++# libgfortran -- and with it libgfortran's own libquadmath dependency -- out |
| 53 | ++# of the result. |
| 54 | ++LIBGFORTRAN_COMPAT_LINK = $(LIBGFORTRAN_COMPAT) -Wl,-dead_strip_dylibs |
| 55 | ++else |
| 56 | ++LIBGFORTRAN_COMPAT_LINK = -Wl,--exclude-libs,$(notdir $(LIBGFORTRAN_COMPAT)) $(LIBGFORTRAN_COMPAT) |
| 57 | ++endif |
| 58 | ++FEXTRALIB += $(LIBGFORTRAN_COMPAT_LINK) |
| 59 | ++endif |
| 60 | ++endif |
| 61 | ++ |
| 62 | ++export LIBGFORTRAN_COMPAT |
| 63 | ++export LIBGFORTRAN_COMPAT_LINK |
| 64 | ++export NO_LIBGFORTRAN |
| 65 | + export NO_FBLAS |
| 66 | + export EXTRALIB |
| 67 | + export CEXTRALIB |
| 68 | +diff --git a/exports/Makefile b/exports/Makefile |
| 69 | +index c4633143b..55f086297 100644 |
| 70 | +--- a/exports/Makefile |
| 71 | ++++ b/exports/Makefile |
| 72 | +@@ -213,7 +213,7 @@ else |
| 73 | + ifneq ($(C_COMPILER), LSB) |
| 74 | + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \ |
| 75 | + -Wl,--whole-archive $< -Wl,--no-whole-archive \ |
| 76 | +- -Wl,-soname,$(INTERNALNAME) $(EXTRALIB) |
| 77 | ++ -Wl,-soname,$(INTERNALNAME) $(EXTRALIB) $(LIBGFORTRAN_COMPAT_LINK) |
| 78 | + $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK. |
| 79 | + else |
| 80 | + #for LSB |
0 commit comments