aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2021-03-28 14:48:17 +0100
committerIain Sandoe <iain@sandoe.co.uk>2023-10-22 19:30:02 +0100
commit6a6d3817afa02bbcd2388c8e005da6faf88932f1 (patch)
treef5997d899baddd1788da7a28f48bfbaa278355f9 /libgcc
parent829b0c4cbabbe5056b79a8a1ec4cd9e9d928a5fb (diff)
downloadgcc-6a6d3817afa02bbcd2388c8e005da6faf88932f1.zip
gcc-6a6d3817afa02bbcd2388c8e005da6faf88932f1.tar.gz
gcc-6a6d3817afa02bbcd2388c8e005da6faf88932f1.tar.bz2
Config,Darwin: Allow for configuring Darwin to use embedded runpath.
Recent Darwin versions place contraints on the use of run paths specified in environment variables. This breaks some assumptions in the GCC build. This change allows the user to configure a Darwin build to use '@rpath/libraryname.dylib' in library names and then to add an embedded runpath to executables (and libraries with dependents). The embedded runpath is added by default unless the user adds '-nodefaultrpaths' to the link line. For an installed compiler, it means that any executable built with that compiler will reference the runtimes installed with the compiler (equivalent to hard-coding the library path into the name of the library). During build-time configurations any "-B" entries will be added to the runpath thus the newly-built libraries will be found by exes. Since the install name is set in libtool, that decision needs to be available here (but might also cause dependent ones in Makefiles, so we need to export a conditional). This facility is not available for Darwin 8 or earlier, however the existing environment variable runpath does work there. We default this on for systems where the external DYLD_LIBRARY_PATH does not work and off for Darwin 8 or earlier. For systems that can use either method, if the value is unset, we use the default (which is currently DYLD_LIBRARY_PATH). ChangeLog: * configure: Regenerate. * configure.ac: Do not add default runpaths to GCC exes when we are building -static-libstdc++/-static-libgcc (the default). * libtool.m4: Add 'enable-darwin-at-runpath'. Act on the enable flag to alter Darwin libraries to use @rpath names. gcc/ChangeLog: * aclocal.m4: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * config/darwin.h: Handle Darwin rpaths. * config/darwin.opt: Handle Darwin rpaths. * Makefile.in: Handle Darwin rpaths. gcc/ada/ChangeLog: * gcc-interface/Makefile.in: Handle Darwin rpaths. gcc/jit/ChangeLog: * Make-lang.in: Handle Darwin rpaths. libatomic/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libbacktrace/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libgcc/ChangeLog: * config/t-slibgcc-darwin: Generate libgcc_s with an @rpath name. * config.host: Handle Darwin rpaths. libgfortran/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths libgm2/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * libm2cor/Makefile.am: Handle Darwin rpaths. * libm2cor/Makefile.in: Regenerate. * libm2iso/Makefile.am: Handle Darwin rpaths. * libm2iso/Makefile.in: Regenerate. * libm2log/Makefile.am: Handle Darwin rpaths. * libm2log/Makefile.in: Regenerate. * libm2min/Makefile.am: Handle Darwin rpaths. * libm2min/Makefile.in: Regenerate. * libm2pim/Makefile.am: Handle Darwin rpaths. * libm2pim/Makefile.in: Regenerate. libgomp/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths libitm/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libobjc/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libphobos/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * libdruntime/Makefile.am: Handle Darwin rpaths. * libdruntime/Makefile.in: Regenerate. * src/Makefile.am: Handle Darwin rpaths. * src/Makefile.in: Regenerate. libquadmath/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libsanitizer/ChangeLog: * asan/Makefile.am: Handle Darwin rpaths. * asan/Makefile.in: Regenerate. * configure: Regenerate. * hwasan/Makefile.am: Handle Darwin rpaths. * hwasan/Makefile.in: Regenerate. * lsan/Makefile.am: Handle Darwin rpaths. * lsan/Makefile.in: Regenerate. * tsan/Makefile.am: Handle Darwin rpaths. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.am: Handle Darwin rpaths. * ubsan/Makefile.in: Regenerate. libssp/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libstdc++-v3/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * src/Makefile.am: Handle Darwin rpaths. * src/Makefile.in: Regenerate. libvtv/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. lto-plugin/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. zlib/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths.
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/config.host23
-rw-r--r--libgcc/config/t-darwin-rpath2
-rw-r--r--libgcc/config/t-slibgcc-darwin28
3 files changed, 40 insertions, 13 deletions
diff --git a/libgcc/config.host b/libgcc/config.host
index a676b2f..6afe8e5 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -233,7 +233,6 @@ case ${host} in
;;
esac
tmake_file="$tmake_file t-slibgcc-darwin"
- # newer toolsets produce warnings when building for unsupported versions.
case ${host} in
*-*-darwin1[89]* | *-*-darwin2* )
tmake_file="t-darwin-min-8 $tmake_file"
@@ -251,6 +250,28 @@ case ${host} in
echo "Warning: libgcc configured to support macOS 10.5" 1>&2
;;
esac
+ # We are not using libtool to build the libs here, so we need to replicate
+ # a little of the logic around setting Darwin rpaths. Setting an explicit
+ # yes or no is honoured, otherwise we choose a suitable default.
+ # Sadly, this has to be kept in line with the rules in libtool.m4.
+ # This make fragment will override the setting in t-slibgcc-darwin so it
+ # must appear after it.
+ if test "x$enable_darwin_at_rpath" = "x"; then
+ echo "enable_darwin_at_rpath is unset" 1>&2
+ case ${host} in
+ *-darwin[45678]*) ;;
+ *-darwin9* | *-darwin1[01234]*) ;; # We might default these on later.
+ *-darwin*)
+ echo "but is needed after macOS 10.11 (setting it on)" 1>&2
+ enable_darwin_at_rpath=yes
+ ;;
+ esac
+ else
+ echo "enable_darwin_at_rpath is '$enable_darwin_at_rpath'" 1>&2
+ fi
+ if test "x$enable_darwin_at_rpath" = "xyes"; then
+ tmake_file="$tmake_file t-darwin-rpath "
+ fi
extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a"
;;
*-*-dragonfly*)
diff --git a/libgcc/config/t-darwin-rpath b/libgcc/config/t-darwin-rpath
new file mode 100644
index 0000000..e73d7f3
--- /dev/null
+++ b/libgcc/config/t-darwin-rpath
@@ -0,0 +1,2 @@
+# Use @rpath and add a search path to exes and dylibs that depend on this.
+SHLIB_RPATH = @rpath
diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin
index cb0cbbd..da48868 100644
--- a/libgcc/config/t-slibgcc-darwin
+++ b/libgcc/config/t-slibgcc-darwin
@@ -1,4 +1,4 @@
-# Build a shared libgcc library with the darwin linker.
+# Build a shared libgcc library able to use embedded runpaths.
SHLIB_SOVERSION = 1.1
SHLIB_SO_MINVERSION = 1
@@ -6,7 +6,6 @@ SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) \
-current_version $(SHLIB_SOVERSION)
SHLIB_EXT = .dylib
SHLIB_LC = -lSystem
-SHLIB_INSTALL_DIR = $(slibdir)
SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
SHLIB_MKMAP_OPTS = -v leading_underscore=1
@@ -23,11 +22,16 @@ SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
# subdir. The code under MULTIBUILDTOP combines these into a single FAT
# library, that is what we eventually install.
+# When enable_darwin_at_rpath is true, use @rpath instead of $(slibdir) for
+# this and dylibs that depend on this. So this def must come first and be
+# overridden in a make fragment that depends on the rpath setting.
+SHLIB_RPATH = $(slibdir)
+
SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
- -install_name $(SHLIB_INSTALL_DIR)/$(SHLIB_INSTALL_NAME) \
+ -install_name $(SHLIB_RPATH)/$(SHLIB_INSTALL_NAME) \
-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
-Wl,-exported_symbols_list,$(SHLIB_MAP) \
- $(SHLIB_VERSTRING) \
+ $(SHLIB_VERSTRING) -nodefaultrpaths \
@multilib_flags@ @shlib_objs@ $(SHLIB_LC)
# we do our own thing
@@ -63,9 +67,9 @@ EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
mkdir -p $(MULTIDIR)
$(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
- -install_name $(SHLIB_INSTALL_DIR)/$(EHS_INSTNAME) \
+ -install_name $(SHLIB_RPATH)/$(EHS_INSTNAME) \
-o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
- $(LIBEHSOBJS) $(SHLIB_LC)
+ -nodefaultrpaths $(LIBEHSOBJS) $(SHLIB_LC)
all: libgcc_ehs$(SHLIB_EXT)
@@ -122,12 +126,12 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
- $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
+ $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
-o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
-Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
-Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
- -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
- -compatibility_version 1 -current_version 1 ; \
+ -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
+ -compatibility_version 1 -current_version 1.1 ; \
done
$(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
@@ -141,13 +145,13 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
- $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
+ $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
-o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
-Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
-lSystem \
-Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
- -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
- -compatibility_version 1 -current_version 1 ; \
+ -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
+ -compatibility_version 1 -current_version 1.1 ; \
done
$(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*