changeset 943:7f2e6bdfcdcb

Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
author Rob Landley <rob@landley.net>
date Sun, 03 Jan 2010 05:04:35 -0600
parents a0b0e2a7d475
children fc134a13357e
files sources/sections/ccwrap.sh sources/toys/ccwrap.c
diffstat 2 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/sources/sections/ccwrap.sh	Tue Dec 22 12:14:03 2009 -0600
+++ b/sources/sections/ccwrap.sh	Sun Jan 03 05:04:35 2010 -0600
@@ -3,7 +3,7 @@
 # Which compiler do we build the wrapper with?
 
 TEMP="${FROM_ARCH}-cc"
-[ -z "$FROM_ARCH" ] && TEMP="$CC" || LIBTYPE="-DGIMME_AN_S=1"
+[ -z "$FROM_ARCH" ] && TEMP="$CC"
 
 # Copy compiler binaries (if not already present)
 
@@ -49,7 +49,5 @@
 
 # Build wrapper binary
 
-echo "$TEMP" "$SOURCES/toys/ccwrap.c" -Os $CFLAGS \
-  -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}cc" $LIBTYPE $STATIC_FLAGS || dienow
 "$TEMP" "$SOURCES/toys/ccwrap.c" -Os $CFLAGS \
-  -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}cc" $LIBTYPE $STATIC_FLAGS || dienow
+  -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}cc" $STATIC_FLAGS || dienow
--- a/sources/toys/ccwrap.c	Tue Dec 22 12:14:03 2009 -0600
+++ b/sources/toys/ccwrap.c	Sun Jan 03 05:04:35 2010 -0600
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2000 Manuel Novoa III
  * Copyright (C) 2002-2003 Erik Andersen
- * Copyright (C) 2006-2009 Rob Landley <rob@landley.net>
+ * Copyright (C) 2006-2010 Rob Landley <rob@landley.net>
  *
  * Wrapper to use make a C compiler relocatable.
  *
@@ -38,8 +38,6 @@
 
 #define xasprintf(...) do {(void)asprintf(__VA_ARGS__);} while(0)
 
-// #define GIMME_AN_S for wrapper to support --enable-shared toolchain.
-
 // Confirm that a regular file exists, and (optionally) has the executable bit.
 int is_file(char *filename, int has_exe)
 {
@@ -98,13 +96,9 @@
 	return NULL;
 }
 
-#ifndef GIMME_AN_S
-#define GIMME_AN_S 0
-#endif
-
 int main(int argc, char **argv)
 {
-	int linking = 1, use_static_linking = 0, use_shared_libgcc = GIMME_AN_S;
+	int linking = 1, use_static_linking = 0, use_shared_libgcc;
 	int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_shared = 0;
 	int source_count = 0, verbose = 0;
 	int i, argcnt, liblen, lplen;
@@ -192,6 +186,11 @@
 	}
 	if (!devprefix) devprefix = topdir;
 
+	// Do we have libgcc_s.so?
+
+	asprintf(&dlstr, "%s/lib/libgcc_s.so", devprefix);
+	use_shared_libgcc = is_file(dlstr, 0);
+	free(dlstr);
 
 	// Figure out where the dynamic linker is.
 	dlstr = getenv("CCWRAP_DYNAMIC_LINKER");
@@ -356,7 +355,7 @@
 
 				case '-':
 					if (!strncmp(argv[i],"--print-",8)
-						|| !strncmp(argv[1],"--static",8))
+						|| !strncmp(argv[i],"--static",8))
 					{
 						argv[i]++;
 						i--;
@@ -452,7 +451,6 @@
 				cc_argv[argcnt++] = "-lgcc";
 				cc_argv[argcnt++] = "-lgcc_eh";
 			}
-				
 			//cc_argv[argcnt++] = "-Wl,--end-group";
 		}
 		if (ctor_dtor) {