Print "Global Exported" to dump_file from set_range_info.
[official-gcc.git] / libgcc / config / t-slibgcc-darwin
blobda4886848e8c7ff54e9372aabc83cc83fa9477d5
1 # Build a shared libgcc library able to use embedded runpaths.
3 SHLIB_SOVERSION = 1.1
4 SHLIB_SO_MINVERSION = 1
5 SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) \
6                   -current_version $(SHLIB_SOVERSION)
7 SHLIB_EXT = .dylib
8 SHLIB_LC = -lSystem
10 SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
11 SHLIB_MKMAP_OPTS = -v leading_underscore=1
13 # Shorthand expressions for the LINK below, these are substituted in the
14 # link expression.
15 SHLIB_INSTALL_NAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
16 SHLIB_MAP = @shlib_map_file@
17 SHLIB_DIR = @multilib_dir@
18 SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
20 # Darwin only searches in shlib_slibdir for shared libraries, not in
21 # subdirectories.  The link builds one architecture slice in its designated
22 # subdir.  The code under MULTIBUILDTOP combines these into a single FAT
23 # library, that is what we eventually install.
25 # When enable_darwin_at_rpath is true, use @rpath instead of $(slibdir) for
26 # this and dylibs that depend on this.  So this def must come first and be
27 # overridden in a make fragment that depends on the rpath setting.
28 SHLIB_RPATH = $(slibdir)
30 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
31         -install_name $(SHLIB_RPATH)/$(SHLIB_INSTALL_NAME) \
32         -single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
33         -Wl,-exported_symbols_list,$(SHLIB_MAP) \
34         $(SHLIB_VERSTRING) -nodefaultrpaths \
35         @multilib_flags@ @shlib_objs@ $(SHLIB_LC)
37 # we do our own thing
38 SHLIB_INSTALL =
40 LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
42 ifeq ($(BUILD_LIBGCCS1),YES)
44 # We are going to build a libgcc_s.1.dylib so that distributions can
45 # install it for compatibility with binaries linked against the old
46 # libgcc_ext.10.x.dylib stubs.
48 # For systems after macOS 10.7 we can forward the correct unwinder symbols
49 # from libSystem.
51 # For older systems we have to forward an entire library (since they cannot
52 # selectively forward symbols, which means that we cannot forward the unwinder
53 # in /usr/lib/libgcc_s.1.dylib).  We also cannot forward the entire library
54 # since that creates a self-referencing loop when DYLD_LIBRARY_PATH is used.
55 # To provide the unwinder symbols in this case, we build the unwinder into a
56 # separate shared lib (libgcc_ehs) and forward that.
58 # These targets are local to this make fragment, which means that they do not
59 # get the substitutions seen in SHLIB_LINK.
61 ifneq ($(LIBEHSOBJS),)
63 EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
65 # multilib build for a shared EH lib.
67 libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
68         mkdir -p $(MULTIDIR)
69         $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
70         -install_name $(SHLIB_RPATH)/$(EHS_INSTNAME) \
71         -o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
72         -nodefaultrpaths $(LIBEHSOBJS) $(SHLIB_LC)
74 all: libgcc_ehs$(SHLIB_EXT)
76 LGCC_FILES += libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
78 endif
79 endif
81 INSTALL_FILES=$(LGCC_FILES)
83 ifeq ($(BUILD_LIBGCCS1),YES)
84 # Provide libgcc_s.1 for backwards compatibility.
85 INSTALL_FILES += libgcc_s.1.dylib
86 endif
88 # For the toplevel multilib, build FAT dylibs including all the multilibs.
89 ifeq ($(MULTIBUILDTOP),)
91 ifeq ($(enable_shared),yes)
92 all: $(INSTALL_FILES)
93 install-leaf: install-darwin-libgcc-stubs
94 endif
96 libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
97         MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
98         for mlib in $$MLIBS ; do \
99           cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT)  \
100             ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
101         done
102         $(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
103           -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
104         rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
106 ifeq ($(BUILD_LIBGCCS1),YES)
107 ifneq ($(LIBEHSOBJS),)
109 libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_ehs$(SHLIB_EXT)
110         MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
111         for mlib in $$MLIBS ; do \
112           cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT)  \
113             ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
114         done
115         $(LIPO) -output libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
116           -create libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
117         rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
120 libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
121                   libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
122         MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
123         for mlib in $$MLIBS ; do \
124           cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT)  \
125             ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
126           cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT)  \
127             ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
128           arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
129           $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
130             -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
131             -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
132             -Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
133             -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
134             -compatibility_version 1 -current_version 1.1 ; \
135         done
136         $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
137         rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
138         rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
140 else
142 libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
143         MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
144         for mlib in $$MLIBS ; do \
145           cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT)  \
146             ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
147           arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
148           $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \
149             -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
150             -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
151             -lSystem \
152             -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
153             -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \
154             -compatibility_version 1 -current_version 1.1 ; \
155         done
156         $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
157         rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
159 endif
160 endif
162 # Install the shared libraries.
164 install-darwin-libgcc-stubs :
165         $(mkinstalldirs) $(DESTDIR)$(slibdir)
166         if test x$(slibdir) = x; then \
167           for d in $(LGCC_FILES) ; do \
168             $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
169           done; \
170         else \
171           for d in $(INSTALL_FILES) ; do \
172             $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
173           done; \
174         fi
176 else
178 # Do not install shared libraries for multilibs.  Unless we are putting them
179 # in the gcc directory during a build, for compatibility with the pre-top-
180 # level layout.  In that case we provide symlinks to the FAT lib from the
181 # multilib sub-directories.
183 ifeq ($(enable_shared),yes)
184 all: install-darwin-libgcc-links
185 endif
187 install-darwin-libgcc-links:
188         $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
189         for file in $(INSTALL_FILES); do                        \
190           rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file;             \
191           $(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/;       \
192         done
194 endif