changeset 390:a9a9eee9e620

Teach the wrapper script to do the libgcc_s --as-needed stuff when appropriate, and to use an arch-specific name for the unwrapped version so you can have more than one cross compiler in the $PATH.
author Rob Landley <rob@landley.net>
date Sun, 24 Aug 2008 19:29:20 -0500
parents becb1084a427
children 2a31ea4d91c7
files cross-compiler.sh mini-native.sh sources/toys/gcc-uClibc.c
diffstat 3 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/cross-compiler.sh	Fri Aug 15 14:29:14 2008 -0500
+++ b/cross-compiler.sh	Sun Aug 24 19:29:20 2008 -0500
@@ -57,8 +57,9 @@
 # Build and install gcc wrapper script.
 
 cd "${CROSS}"/bin &&
-mv "${ARCH}-gcc" gcc-unwrapped &&
-$CC $STATIC_FLAGS -Os -s "${SOURCES}"/toys/gcc-uClibc.c -o "${ARCH}-gcc"
+mv "${ARCH}-gcc" "$ARCH-rawgcc" &&
+$CC $STATIC_FLAGS -Os -s "${SOURCES}"/toys/gcc-uClibc.c -o "${ARCH}-gcc" \
+  -DGCC_UNWRAPPED_NAME='"$ARCH-rawgcc"'
 EOF
 
 # Run toolchain fixup and cleanup
@@ -71,8 +72,8 @@
 # Set up symlinks for distcc
 
 mkdir -p "${CROSS}/distcc" &&
-ln -s ../bin/gcc-unwrapped "${CROSS}/distcc/cc" &&
-ln -s ../bin/gcc-unwrapped "${CROSS}/distcc/gcc" &&
+ln -s ../bin/"$ARCH-rawgcc" "${CROSS}/distcc/cc" &&
+ln -s ../bin/"$ARCH-rawgcc" "${CROSS}/distcc/gcc" &&
 ln -s ../bin/"$ARCH-as" "${CROSS}/distcc/as"
 
 [ $? -ne 0 ] && dienow
--- a/mini-native.sh	Fri Aug 15 14:29:14 2008 -0500
+++ b/mini-native.sh	Sun Aug 24 19:29:20 2008 -0500
@@ -140,8 +140,9 @@
 mkdir -p "${TOOLS}"/gcc &&
 mv "${TOOLS}"/lib/gcc/*/*/include "${TOOLS}"/gcc/include &&
 mv "${TOOLS}"/lib/gcc/*/* "${TOOLS}"/gcc/lib &&
-mv "${TOOLS}/bin/gcc" "${TOOLS}/bin/gcc-unwrapped" &&
-"${ARCH}-gcc" "${SOURCES}"/toys/gcc-uClibc.c -Os -s -o "${TOOLS}/bin/gcc"
+mv "${TOOLS}/bin/gcc" "${TOOLS}/bin/rawgcc" &&
+"${ARCH}-gcc" "${SOURCES}"/toys/gcc-uClibc.c -Os -s -o "${TOOLS}/bin/gcc" \
+  -DGCC_UNWRAPPED_NAME='"rawgcc"' -DGIMME_AN_S
 
 cleanup "${TOOLS}"/{lib/gcc,gcc/lib/install-tools}
 
--- a/sources/toys/gcc-uClibc.c	Fri Aug 15 14:29:14 2008 -0500
+++ b/sources/toys/gcc-uClibc.c	Sun Aug 24 19:29:20 2008 -0500
@@ -28,6 +28,14 @@
 // For C++
 static char nostdinc_plus[] = "-nostdinc++";
 
+#ifdef GIMME_AN_S
+#define ADD_GCC_S() gcc_argv[argcnt++] = "-Wl,--as-needed,-lgcc_s,--no-as-needed"
+#else
+#define ADD_GCC_S()
+#endif
+
+
+
 
 // Confirm that a regular file exists, and (optionally) has the executable bit.
 int is_file(char *filename, int has_exe)
@@ -134,7 +142,7 @@
 	// What's the name of the C compiler we're wrapping?  (It may have a
 	// cross-prefix.)
 	cc = getenv("UCLIBC_CC");
-	if (!cc) cc = "gcc-unwrapped";
+	if (!cc) cc = GCC_UNWRAPPED_NAME;
 
 	
 	// Check end of name, since there could be a cross-prefix on the thing
@@ -475,6 +483,7 @@
 		if (use_stdlib) {
 			//gcc_argv[argcnt++] = "-Wl,--start-group";
 			gcc_argv[argcnt++] = "-lgcc";
+			ADD_GCC_S();
 //			gcc_argv[argcnt++] = "-lgcc_eh";
 		}
 		for (i = 0 ; i < liblen ; i++)
@@ -486,6 +495,7 @@
 			}
 			gcc_argv[argcnt++] = "-lc";
 			gcc_argv[argcnt++] = "-lgcc";
+			ADD_GCC_S();
 //			gcc_argv[argcnt++] = "-lgcc_eh";
 			//gcc_argv[argcnt++] = "-Wl,--end-group";
 		}