This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] build fat libgcc_s.1.dylib for darwin


Here's a patch that makes libgcc_s.1.dylib fully "fat" or "universal" for darwin. It involves a little rewriting of the makefile dependencies in the file since we don't really have a "post-processing" step for libgcc.

Tested (and install tested) on ppc-darwin (with 64-bit multilib), x86-darwin, no regressions.

OK to hold for 4.3?

-eric

2006-07-10 Eric Christopher <echristo@apple.com>

* config/t-slibgcc-darwin: Rewrite.

Index: gcc/config/t-slibgcc-darwin
===================================================================
--- gcc/config/t-slibgcc-darwin	(revision 115311)
+++ gcc/config/t-slibgcc-darwin	(working copy)
@@ -2,26 +2,28 @@
 SHLIB_SOVERSION = 1
 SHLIB_VERSTRING = -compatibility_version $(SHLIB_SOVERSION) -current_version $(SHLIB_SOVERSION).0
 SHLIB_EXT = .dylib
-SHLIB_SUFFIX = `if test @multilib_dir@ != . ; then echo _@multilib_dir@ ; fi`
-SHLIB_SONAME = @shlib_base_name@$(SHLIB_SUFFIX).$(SHLIB_SOVERSION)$(SHLIB_EXT)
+SHLIB_SUFFIX = `if test @multilib_dir@ == ppc64 ; then echo _@multilib_dir@ ; fi`
+SHLIB_INSTALL_NAME = @shlib_base_name@$(SHLIB_SUFFIX).$(SHLIB_SOVERSION)$(SHLIB_EXT)
+SHLIB_SONAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+SHLIB_SOLINK = @shlib_base_name@.so
 SHLIB_MAP = @shlib_map_file@
 SHLIB_OBJS = @shlib_objs@
 SHLIB_DIR = @multilib_dir@
+SHLIB_LC = -lc
 
 # Darwin only searches in /usr/lib for shared libraries, not in subdirectories,
 # so the libgcc variants have different names not different locations.
 # Note that this version is used for the loader, not the linker; the linker
 # uses the stub versions named by $(LIBGCC).
 SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
-	-Wl,-install_name,$(slibdir)/$(SHLIB_SONAME) \
-	-single_module -o $(SHLIB_SONAME).tmp \
+	-Wl,-install_name,$(slibdir)/$(SHLIB_INSTALL_NAME) \
+	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp \
 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
 	$(SHLIB_VERSTRING) \
-	@multilib_flags@ $(SHLIB_OBJS) -lc && \
-	if [ -f $(SHLIB_SONAME) ]; then \
-	  mv -f $(SHLIB_SONAME) $(SHLIB_SONAME).backup; \
-	else true; fi && \
-	mv $(SHLIB_SONAME).tmp $(SHLIB_SONAME)
+	@multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC) && \
+	if [ -f stmp-lipo ]; then \
+	  rm -f stmp-lipo; \
+	else true; fi
 
 # $(slibdir) double quoted to protect it from expansion while building
 # libgcc.mk.  We want this delayed until actual install time.
@@ -45,7 +47,7 @@ ASM_HIDDEN_OP = .private_extern
 # 
 # This assumes each multilib corresponds to a different architecture.
 libgcc_s.%.dylib : $(SHLIB_VERPFX).%.ver libgcc.a
-	# When builting multilibbed target libraries, all the required
+	# When building multilibbed target libraries, all the required
 	# libraries are expected to exist in the multilib directory.
 	MLIBS=`$(GCC_FOR_TARGET) --print-multi-lib \
 		| sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
@@ -54,22 +56,44 @@ libgcc_s.%.dylib : $(SHLIB_VERPFX).%.ver
 	  $(LN_S) ../$@ $${mlib}/$@ || exit 1 ; \
 	done
 	MLIBS=`$(GCC_FOR_TARGET) --print-multi-lib \
-		| sed -e 's/;.*$$//' -e '/^\.$$/d' -e 's/^/_/'` ; \
+		| sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
 	for mlib in '' $$MLIBS ; do \
 	  $(STRIP_FOR_TARGET) -o $(@)_T$${mlib} \
 	    -s $(SHLIB_VERPFX).$(*).ver -c -u \
-	    libgcc_s$${mlib}.$(SHLIB_SOVERSION)$(SHLIB_EXT) || exit 1 ; \
+	    ./$${mlib}/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp || exit 1 ; \
 	done
 	$(LIPO_FOR_TARGET) -output $@ -create $(@)_T*
 	rm $(@)_T*
 
+stmp-lipo: libgcc_s.10.4.dylib libgcc_s.10.5.dylib
+	# When building multilibbed target libraries, all the required
+	# libraries are expected to exist in the multilib directory.
+	MLIBS=`$(GCC_FOR_TARGET) --print-multi-lib \
+		| sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
+	for mlib in '' $$MLIBS ; do \
+	  cp ./$${mlib}/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp \
+	    ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
+	done
+	$(LIPO_FOR_TARGET) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
+	  -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+	rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+	$(STAMP) stmp-lipo
+
 # From the point-of-view of the Makefiles, libgcc is built by the 'strip'
 # and 'lipo' commands above.
-LIBGCC=libgcc_s.10.4.dylib libgcc_s.10.5.dylib
+LIBGCC=stmp-lipo
+
+INSTALL_FILES=libgcc_s.10.4.dylib libgcc_s.10.5.dylib libgcc_s.1.dylib
 
-install-darwin-libgcc-stubs : $(LIBGCC) installdirs
-	for d in $(LIBGCC) ; do \
+install-darwin-libgcc-stubs : $(INSTALL_FILES) installdirs install-multilib \
+			 	stmp-lipo
+	for d in $(INSTALL_FILES) ; do \
 	  $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
 	done
+	if [ -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib ]; then \
+	  rm -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib; \
+	else true; fi
+	$(LN_S) $(DESTDIR)$(slibdir)/libgcc_s.1.dylib \
+		$(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib
 
 INSTALL_LIBGCC += install-darwin-libgcc-stubs

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]