mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
6a6d3817af
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.
195 lines
7.0 KiB
Plaintext
195 lines
7.0 KiB
Plaintext
# Build a shared libgcc library able to use embedded runpaths.
|
|
|
|
SHLIB_SOVERSION = 1.1
|
|
SHLIB_SO_MINVERSION = 1
|
|
SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) \
|
|
-current_version $(SHLIB_SOVERSION)
|
|
SHLIB_EXT = .dylib
|
|
SHLIB_LC = -lSystem
|
|
|
|
SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
|
|
SHLIB_MKMAP_OPTS = -v leading_underscore=1
|
|
|
|
# Shorthand expressions for the LINK below, these are substituted in the
|
|
# link expression.
|
|
SHLIB_INSTALL_NAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
|
SHLIB_MAP = @shlib_map_file@
|
|
SHLIB_DIR = @multilib_dir@
|
|
SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
|
|
|
|
# Darwin only searches in shlib_slibdir for shared libraries, not in
|
|
# subdirectories. The link builds one architecture slice in its designated
|
|
# 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_RPATH)/$(SHLIB_INSTALL_NAME) \
|
|
-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
|
|
-Wl,-exported_symbols_list,$(SHLIB_MAP) \
|
|
$(SHLIB_VERSTRING) -nodefaultrpaths \
|
|
@multilib_flags@ @shlib_objs@ $(SHLIB_LC)
|
|
|
|
# we do our own thing
|
|
SHLIB_INSTALL =
|
|
|
|
LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
|
|
|
ifeq ($(BUILD_LIBGCCS1),YES)
|
|
|
|
# We are going to build a libgcc_s.1.dylib so that distributions can
|
|
# install it for compatibility with binaries linked against the old
|
|
# libgcc_ext.10.x.dylib stubs.
|
|
|
|
# For systems after macOS 10.7 we can forward the correct unwinder symbols
|
|
# from libSystem.
|
|
|
|
# For older systems we have to forward an entire library (since they cannot
|
|
# selectively forward symbols, which means that we cannot forward the unwinder
|
|
# in /usr/lib/libgcc_s.1.dylib). We also cannot forward the entire library
|
|
# since that creates a self-referencing loop when DYLD_LIBRARY_PATH is used.
|
|
# To provide the unwinder symbols in this case, we build the unwinder into a
|
|
# separate shared lib (libgcc_ehs) and forward that.
|
|
|
|
# These targets are local to this make fragment, which means that they do not
|
|
# get the substitutions seen in SHLIB_LINK.
|
|
|
|
ifneq ($(LIBEHSOBJS),)
|
|
|
|
EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
|
|
|
# multilib build for a shared EH lib.
|
|
|
|
libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
|
|
mkdir -p $(MULTIDIR)
|
|
$(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
|
|
-install_name $(SHLIB_RPATH)/$(EHS_INSTNAME) \
|
|
-o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
|
|
-nodefaultrpaths $(LIBEHSOBJS) $(SHLIB_LC)
|
|
|
|
all: libgcc_ehs$(SHLIB_EXT)
|
|
|
|
LGCC_FILES += libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
|
|
|
endif
|
|
endif
|
|
|
|
INSTALL_FILES=$(LGCC_FILES)
|
|
|
|
ifeq ($(BUILD_LIBGCCS1),YES)
|
|
# Provide libgcc_s.1 for backwards compatibility.
|
|
INSTALL_FILES += libgcc_s.1.dylib
|
|
endif
|
|
|
|
# For the toplevel multilib, build FAT dylibs including all the multilibs.
|
|
ifeq ($(MULTIBUILDTOP),)
|
|
|
|
ifeq ($(enable_shared),yes)
|
|
all: $(INSTALL_FILES)
|
|
install-leaf: install-darwin-libgcc-stubs
|
|
endif
|
|
|
|
libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
|
for mlib in $$MLIBS ; do \
|
|
cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
|
|
./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
|
|
done
|
|
$(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
|
|
-create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
|
rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
|
|
|
ifeq ($(BUILD_LIBGCCS1),YES)
|
|
ifneq ($(LIBEHSOBJS),)
|
|
|
|
libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_ehs$(SHLIB_EXT)
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
|
for mlib in $$MLIBS ; do \
|
|
cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
|
|
./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
|
|
done
|
|
$(LIPO) -output libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
|
|
-create libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
|
rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
|
|
|
|
|
libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
|
|
libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
|
for mlib in $$MLIBS ; do \
|
|
cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
|
|
./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
|
|
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 -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_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*
|
|
rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
|
|
|
else
|
|
|
|
libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
|
for mlib in $$MLIBS ; do \
|
|
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 -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_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*
|
|
|
|
endif
|
|
endif
|
|
|
|
# Install the shared libraries.
|
|
|
|
install-darwin-libgcc-stubs :
|
|
$(mkinstalldirs) $(DESTDIR)$(slibdir)
|
|
if test x$(slibdir) = x; then \
|
|
for d in $(LGCC_FILES) ; do \
|
|
$(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
|
|
done; \
|
|
else \
|
|
for d in $(INSTALL_FILES) ; do \
|
|
$(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
|
|
done; \
|
|
fi
|
|
|
|
else
|
|
|
|
# Do not install shared libraries for multilibs. Unless we are putting them
|
|
# in the gcc directory during a build, for compatibility with the pre-top-
|
|
# level layout. In that case we provide symlinks to the FAT lib from the
|
|
# multilib sub-directories.
|
|
|
|
ifeq ($(enable_shared),yes)
|
|
all: install-darwin-libgcc-links
|
|
endif
|
|
|
|
install-darwin-libgcc-links:
|
|
$(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
|
|
for file in $(INSTALL_FILES); do \
|
|
rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
|
|
$(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/; \
|
|
done
|
|
|
|
endif
|