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]

Re: CFT: Top level libgcc for Darwin


On Sun, Nov 26, 2006 at 03:07:18PM -0500, Daniel Jacobowitz wrote:
> I've committed this patch, based on an older version Paolo sent me,
> to branches/libgcc-toplevel.  I believe it will work, but the whole
> Darwin libgcc setup is very confusing to me, and seems to have some
> preexisting problems (for instance, SHLIB_LINK does not generate the
> expected file "libgcc_s.dylib", so make may rerun things
> unnecessarily).  So, I really need someone to test this on Darwin
> for me, preferably with multilibs.  If you give it a try, please
> let me know.

Andrew worked through this with me on IRC, and Eric gave it a final
test.  Here's the additional changes needed for Darwin support on the
branch.

-- 
Daniel Jacobowitz
CodeSourcery

2006-11-26  Daniel Jacobowitz  <dan@codesourcery.com>

	* config/i386/t-darwin (SHLIB_VERPFX): Don't set.
	* config/i386/t-darwin64 (SHLIB_VERPFX): Likewise.
	* config/rs6000/t-darwin (SHLIB_VERPFX): Likewise.
	
2006-11-26  Daniel Jacobowitz  <dan@codesourcery.com>

	* config/t-slibgcc-darwin (SHLIB_LINK): Doc fix.
	(SHLIB_INSTALL): Only define for the top multilib.
	(INSTALL_FILES): Always set.
	(libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)): Remove redundant rule.
	(libgcc_s.%.dylib): Correct path.
	(libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)): Likewise.
	(install-darwin-libgcc-links): New.
	* config/rs6000/t-darwin: New file.
	* config/i386/t-darwin, config/i386/t-darwin64: New files.
	* config.gcc: Initialize cpu_type.  Handle Darwin.
	* Makefile.in: Update comments.

--- gcc/config/i386/t-darwin	(revision 119266)
+++ gcc/config/i386/t-darwin	(local)
@@ -1,4 +1,3 @@
-SHLIB_VERPFX = $(srcdir)/config/i386/darwin-libgcc
 MULTILIB_OPTIONS = m64
 MULTILIB_DIRNAMES = x86_64
 LIB2_SIDITI_CONV_FUNCS=yes
--- gcc/config/i386/t-darwin64	(revision 119266)
+++ gcc/config/i386/t-darwin64	(local)
@@ -1,3 +1,2 @@
-SHLIB_VERPFX = $(srcdir)/config/i386/darwin-libgcc
 LIB2_SIDITI_CONV_FUNCS=yes
 LIB2FUNCS_EXTRA = $(srcdir)/config/darwin-64.c
--- gcc/config/rs6000/t-darwin	(revision 119266)
+++ gcc/config/rs6000/t-darwin	(local)
@@ -23,8 +23,6 @@ TARGET_LIBGCC2_CFLAGS = -Wa,-force_cpusu
 # Export the _xlq* symbols from darwin-ldouble.c.
 SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ppc64.ver
 
-SHLIB_VERPFX = $(srcdir)/config/rs6000/darwin-libgcc
-
 LIB2ADDEH += $(srcdir)/config/rs6000/darwin-fallback.c
 
 darwin-fpsave.o:	$(srcdir)/config/rs6000/darwin-asm.h
--- libgcc/config/rs6000/t-darwin	(revision 119266)
+++ libgcc/config/rs6000/t-darwin	(local)
@@ -0,0 +1 @@
+SHLIB_VERPFX = $(gcc_srcdir)/config/rs6000/darwin-libgcc
--- libgcc/config/t-slibgcc-darwin	(revision 119266)
+++ libgcc/config/t-slibgcc-darwin	(local)
@@ -14,7 +14,7 @@ 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).
+# uses the stub versions named by the versioned members of $(INSTALL_FILES).
 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
 	-Wl,-install_name,$(slibdir)/$(SHLIB_INSTALL_NAME) \
 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp \
@@ -22,11 +22,6 @@ SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dy
 	$(SHLIB_VERSTRING) \
 	@multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC)
 
-SHLIB_INSTALL = \
-	$(mkinstalldirs) $(DESTDIR)$(slibdir); \
-	$(INSTALL_DATA) $(SHLIB_SONAME) \
-	  $(DESTDIR)$(slibdir)/$(SHLIB_SONAME)
-
 SHLIB_MKMAP = $(gcc_srcdir)/mkmap-flat.awk
 SHLIB_MKMAP_OPTS = -v leading_underscore=1
 SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-std.ver
@@ -34,16 +29,21 @@ SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-s
 # Must use a different directive for hidden visibility in assembly sources.
 ASM_HIDDEN_OP = .private_extern
 
+INSTALL_FILES=libgcc_s.10.4.dylib libgcc_s.10.5.dylib libgcc_s.1.dylib
+
 # For the toplevel multilib, build a fat archive including all the multilibs.
 ifeq ($(MULTIBUILDTOP),)
 
+SHLIB_INSTALL = \
+	$(mkinstalldirs) $(DESTDIR)$(slibdir); \
+	$(INSTALL_DATA) $(SHLIB_SONAME) \
+	  $(DESTDIR)$(slibdir)/$(SHLIB_SONAME)
+
 ifeq ($(enable_shared),yes)
 HOST_EXTRA = $(INSTALL_FILES)
 HOST_EXTRA_INSTALL = install-darwin-libgcc-stubs
 endif
 
-libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) : libgcc_s$(SHLIB_EXT)
-
 # In order to support -mmacosx-version-min, you need to have multiple
 # different libgcc_s libraries that actually get linked against, one for
 # each system version supported.  They are 'stub' libraries that
@@ -60,7 +60,7 @@ libgcc_s.%.dylib : $(SHLIB_VERPFX).%.ver
 	for mlib in $$MLIBS ; do \
 	  $(STRIP) -o $(@)_T$${mlib} \
 	    -s $(SHLIB_VERPFX).$(*).ver -c -u \
-	    ../$${mlib}/libgcc/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp || exit 1 ; \
+	    ../$${mlib}/libgcc/$${mlib}/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp || exit 1 ; \
 	done
 	$(LIPO) -output $@ -create $(@)_T*
 	rm $(@)_T*
@@ -72,15 +72,13 @@ libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT):
 	MLIBS=`$(CC) --print-multi-lib \
 		| sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
 	for mlib in $$MLIBS ; do \
-	  cp ../$${mlib}/libgcc/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp \
+	  cp ../$${mlib}/libgcc/$${mlib}/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp \
 	    ./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*
 
-INSTALL_FILES=libgcc_s.10.4.dylib libgcc_s.10.5.dylib libgcc_s.1.dylib
-
 install-darwin-libgcc-stubs : $(INSTALL_FILES)
 	$(mkinstalldirs) $(DESTDIR)$(slibdir)
 	for d in $(INSTALL_FILES) ; do \
@@ -97,4 +95,31 @@ install-darwin-libgcc-stubs : $(INSTALL_
 	$(LN_S) libgcc_s.1.dylib \
 		$(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib
 
+else
+
+# Do not install shared libraries for any other multilibs.  Unless
+# we're putting them in the gcc directory during a build, for
+# compatibility with the pre-top-level layout.  In that case we
+# need symlinks.
+SHLIB_INSTALL =
+
+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
+
+	rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
+	$(LN_S) libgcc_s.1.dylib \
+		$(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
+
+	rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
+	$(LN_S) libgcc_s.1.dylib \
+		$(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
+
 endif
--- libgcc/config/i386/t-darwin	(revision 119266)
+++ libgcc/config/i386/t-darwin	(local)
@@ -0,0 +1 @@
+SHLIB_VERPFX = $(gcc_srcdir)/config/i386/darwin-libgcc
--- libgcc/config/i386/t-darwin64	(revision 119266)
+++ libgcc/config/i386/t-darwin64	(local)
@@ -0,0 +1 @@
+SHLIB_VERPFX = $(gcc_srcdir)/config/i386/darwin-libgcc
--- libgcc/config.gcc	(revision 119266)
+++ libgcc/config.gcc	(local)
@@ -40,14 +40,94 @@
 
 hmake_file=$cpu_type/t-$cpu_type
 
+# Set default cpu_type.
+cpu_type=`echo ${host} | sed 's/-.*$//'`
+case ${host} in
+m32c*-*-*)
+        cpu_type=m32c
+        ;;
+alpha*-*-*)
+	cpu_type=alpha
+	;;
+am33_2.0-*-linux*)
+	cpu_type=mn10300
+	;;
+strongarm*-*-*)
+	cpu_type=arm
+	;;
+arm*-*-*)
+	cpu_type=arm
+	;;
+bfin*-*)
+	cpu_type=bfin
+	;;
+ep9312*-*-*)
+	cpu_type=arm
+	;;
+frv*)	cpu_type=frv
+	;;
+xscale-*-*)
+	cpu_type=arm
+	;;
+i[34567]86-*-*)
+	cpu_type=i386
+	;;
+x86_64-*-*)
+	cpu_type=i386
+	;;
+ia64-*-*)
+	extra_headers=ia64intrin.h
+	;;
+hppa*-*-* | parisc*-*-*)
+	cpu_type=pa
+	;;
+m32r*-*-*)
+        cpu_type=m32r
+        ;;
+m680[012]0-*-*)
+	cpu_type=m68k
+	;;
+mips*-*-*)
+	cpu_type=mips
+	;;
+powerpc*-*-*)
+	cpu_type=rs6000
+	;;
+score*-*-*)
+	cpu_type=score
+	;;
+sparc64*-*-*)
+	cpu_type=sparc
+	;;
+sparc*-*-*)
+	cpu_type=sparc
+	;;
+spu*-*-*)
+	cpu_type=spu
+	;;
+s390*-*-*)
+	cpu_type=s390
+	;;
+# Note the 'l'; we need to be able to match e.g. "shle" or "shl".
+sh[123456789lbe]*-*-*)
+	cpu_type=sh
+	;;
+tic4x-*-*)
+        cpu_type=c4x
+        ;;
+esac
+
 # Common parts for widely ported systems.
 case ${host} in
 *-*-darwin*)
-	hmake_file="${hmake_file} t-slibgcc-darwin"
+	hmake_file="t-darwin ${cpu_type}/t-darwin t-slibgcc-darwin"
 	;;
 esac
 
 case ${host} in
+x86_64-*-darwin*)
+	hmake_file="t-darwin ${cpu_type}/t-darwin64 t-slibgcc-darwin"
+	;;
 powerpc64-*-linux*)
 	hmake_file="${hmake_file} rs6000/t-ldbl128"
 	;;
--- libgcc/Makefile.in	(revision 119266)
+++ libgcc/Makefile.in	(local)
@@ -733,7 +733,8 @@ include $(srcdir)/empty.mk $(wildcard *.
 
 # FIXME QUEUE:
 #  Darwin and i386-netware (t-nwld) have additional rules needed to build
-#  bits of shared libgcc.
+#  bits of shared libgcc.  Darwin's are handled and need to be garbage
+#  collected from gcc/.  Netware's need handling.
 
 # TODO QUEUE:
 #   Garbage collect in gcc/:


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