1 # Build a shared libgcc library with the darwin linker.
4 SHLIB_SO_MINVERSION = 1
5 SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) \
6 -current_version $(SHLIB_SOVERSION)
9 SHLIB_INSTALL_DIR = $(slibdir)
11 SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
12 SHLIB_MKMAP_OPTS = -v leading_underscore=1
14 # Shorthand expressions for the LINK below, these are substituted in the
16 SHLIB_INSTALL_NAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
17 SHLIB_MAP = @shlib_map_file@
18 SHLIB_DIR = @multilib_dir@
19 SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
21 # Darwin only searches in shlib_slibdir for shared libraries, not in
22 # subdirectories. The link builds one architecture slice in its designated
23 # subdir. The code under MULTIBUILDTOP combines these into a single FAT
24 # library, that is what we eventually install.
26 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
27 -install_name $(SHLIB_INSTALL_DIR)/$(SHLIB_INSTALL_NAME) \
28 -single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
29 -Wl,-exported_symbols_list,$(SHLIB_MAP) \
31 @multilib_flags@ @shlib_objs@ $(SHLIB_LC)
36 LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
38 ifeq ($(BUILD_LIBGCCS1),YES)
40 # We are going to build a libgcc_s.1.dylib so that distributions can
41 # install it for compatibility with binaries linked against the old
42 # libgcc_ext.10.x.dylib stubs.
44 # For systems after macOS 10.7 we can forward the correct unwinder symbols
47 # For older systems we have to forward an entire library (since they cannot
48 # selectively forward symbols, which means that we cannot forward the unwinder
49 # in /usr/lib/libgcc_s.1.dylib). We also cannot forward the entire library
50 # since that creates a self-referencing loop when DYLD_LIBRARY_PATH is used.
51 # To provide the unwinder symbols in this case, we build the unwinder into a
52 # separate shared lib (libgcc_ehs) and forward that.
54 # These targets are local to this make fragment, which means that they do not
55 # get the substitutions seen in SHLIB_LINK.
57 ifneq ($(LIBEHSOBJS),)
59 EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
61 # multilib build for a shared EH lib.
63 libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
65 $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
66 -install_name $(SHLIB_INSTALL_DIR)/$(EHS_INSTNAME) \
67 -o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
68 $(LIBEHSOBJS) $(SHLIB_LC)
70 all: libgcc_ehs$(SHLIB_EXT)
72 LGCC_FILES += libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
77 INSTALL_FILES=$(LGCC_FILES)
79 ifeq ($(BUILD_LIBGCCS1),YES)
80 # Provide libgcc_s.1 for backwards compatibility.
81 INSTALL_FILES += libgcc_s.1.dylib
84 # For the toplevel multilib, build FAT dylibs including all the multilibs.
85 ifeq ($(MULTIBUILDTOP),)
87 ifeq ($(enable_shared),yes)
89 install-leaf: install-darwin-libgcc-stubs
92 libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
93 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
94 for mlib in $$MLIBS ; do \
95 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
96 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
98 $(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
99 -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
100 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
102 ifeq ($(BUILD_LIBGCCS1),YES)
103 ifneq ($(LIBEHSOBJS),)
105 libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_ehs$(SHLIB_EXT)
106 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
107 for mlib in $$MLIBS ; do \
108 cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
109 ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
111 $(LIPO) -output libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
112 -create libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
113 rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
116 libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
117 libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
118 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
119 for mlib in $$MLIBS ; do \
120 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
121 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
122 cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
123 ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
124 arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
125 $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
126 -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
127 -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
128 -Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
129 -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
130 -compatibility_version 1 -current_version 1 ; \
132 $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
133 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
134 rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
138 libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
139 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
140 for mlib in $$MLIBS ; do \
141 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
142 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
143 arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
144 $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
145 -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
146 -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
148 -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
149 -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
150 -compatibility_version 1 -current_version 1 ; \
152 $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
153 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
158 # Install the shared libraries.
160 install-darwin-libgcc-stubs :
161 $(mkinstalldirs) $(DESTDIR)$(slibdir)
162 if test x$(slibdir) = x; then \
163 for d in $(LGCC_FILES) ; do \
164 $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
167 for d in $(INSTALL_FILES) ; do \
168 $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
174 # Do not install shared libraries for multilibs. Unless we are putting them
175 # in the gcc directory during a build, for compatibility with the pre-top-
176 # level layout. In that case we provide symlinks to the FAT lib from the
177 # multilib sub-directories.
179 ifeq ($(enable_shared),yes)
180 all: install-darwin-libgcc-links
183 install-darwin-libgcc-links:
184 $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
185 for file in $(INSTALL_FILES); do \
186 rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
187 $(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/; \