1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
# 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
|