t-slibgcc-darwin revision 1.1.1.3 1 # Build a shared libgcc library with the darwin linker.
2
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
9 SHLIB_INSTALL_DIR = $(slibdir)
10
11 SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
12 SHLIB_MKMAP_OPTS = -v leading_underscore=1
13
14 # Shorthand expressions for the LINK below, these are substituted in the
15 # link expression.
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)
20
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.
25
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) \
30 $(SHLIB_VERSTRING) \
31 @multilib_flags@ @shlib_objs@ $(SHLIB_LC)
32
33 # we do our own thing
34 SHLIB_INSTALL =
35
36 LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
37
38 ifeq ($(BUILD_LIBGCCS1),YES)
39
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.
43
44 # For systems after macOS 10.7 we can forward the correct unwinder symbols
45 # from libSystem.
46
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.
53
54 # These targets are local to this make fragment, which means that they do not
55 # get the substitutions seen in SHLIB_LINK.
56
57 ifneq ($(LIBEHSOBJS),)
58
59 EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
60
61 # multilib build for a shared EH lib.
62
63 libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
64 mkdir -p $(MULTIDIR)
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)
69
70 all: libgcc_ehs$(SHLIB_EXT)
71
72 LGCC_FILES += libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
73
74 endif
75
76 # Provide libgcc_s.1 for backwards compatibility.
77 LGCC_FILES += libgcc_s.1.dylib
78
79 endif
80
81 INSTALL_FILES=$(LGCC_FILES)
82
83 # For the toplevel multilib, build FAT dylibs including all the multilibs.
84 ifeq ($(MULTIBUILDTOP),)
85
86 ifeq ($(enable_shared),yes)
87 all: $(INSTALL_FILES)
88 install-leaf: install-darwin-libgcc-stubs
89 endif
90
91 libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
92 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
93 for mlib in $$MLIBS ; do \
94 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
95 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
96 done
97 $(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
98 -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
99 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
100
101 ifeq ($(BUILD_LIBGCCS1),YES)
102 ifneq ($(LIBEHSOBJS),)
103
104 libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_ehs$(SHLIB_EXT)
105 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
106 for mlib in $$MLIBS ; do \
107 cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
108 ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
109 done
110 $(LIPO) -output libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
111 -create libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
112 rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
113
114
115 libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
116 libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
117 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
118 for mlib in $$MLIBS ; do \
119 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
120 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
121 cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
122 ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
123 arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
124 $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
125 -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
126 -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
127 -Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
128 -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
129 -compatibility_version 1 -current_version 1 ; \
130 done
131 $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
132 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
133 rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
134
135 else
136
137 libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
138 MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
139 for mlib in $$MLIBS ; do \
140 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
141 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
142 arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
143 $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
144 -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
145 -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
146 -lSystem \
147 -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
148 -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
149 -compatibility_version 1 -current_version 1 ; \
150 done
151 $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
152 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
153
154 endif
155 endif
156
157 # Install the shared libraries.
158
159 install-darwin-libgcc-stubs :
160 $(mkinstalldirs) $(DESTDIR)$(slibdir)
161 for d in $(INSTALL_FILES) ; do \
162 $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
163 done
164
165 else
166
167 # Do not install shared libraries for multilibs. Unless we are putting them
168 # in the gcc directory during a build, for compatibility with the pre-top-
169 # level layout. In that case we provide symlinks to the FAT lib from the
170 # multilib sub-directories.
171
172 ifeq ($(enable_shared),yes)
173 all: install-darwin-libgcc-links
174 endif
175
176 install-darwin-libgcc-links:
177 $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
178 for file in $(INSTALL_FILES); do \
179 rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
180 $(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/; \
181 done
182
183 endif
184