fix PR 31013, objc -shared-libgcc problems on Darwin

Geoffrey Keating gkeating@apple.com
Thu Mar 8 20:19:00 GMT 2007


There was a testsuite failure, which I tracked down to problems in
gccspec.c.  gccspec.c tries to recognize when an Objective-C file is
being compiled and add -shared-libgcc.  This was added to work around
problems in the testsuite
<http://gcc.gnu.org/ml/gcc-patches/2001-03/msg00427.html>, but now the
GNU runtime is depending on it for exception handling.

On Darwin, with the NeXT runtime, this is wrong; a program built
against the NeXT runtime can run right back on 10.1 which doesn't have
any shared libgcc available.  On other platforms this is broken,
because it doesn't handle -x options; I filed that as PR 31089.

This fixes the Darwin problems, reported as PR 31013, by suppressing
all this code and doing the right thing with specs keyed off the
presence of -fgnu-runtime.

I'll put this in the 4.2 branch as well, after waiting a while to
ensure there aren't any unexpected side-effects, since it is a
regression (it'd have worked in at least 2.95).  It's not a very
serious regression, since it only happens to people who use 'gcc foo.m
-o foo' and people don't usually compile and link in a single step,
but I think still worth fixing.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-pr31013.patch=========================
2007-03-08  Geoffrey Keating  <geoffk@apple.com>

	PR 31013
	* gccspec.c (lang_specific_driver): Do nothing when NEXT_OBJC_RUNTIME
	is declared.
	* config/darwin.h (REAL_LIBGCC_SPEC): When -fgnu-runtime is
	passed, use shared libgcc.

Index: gcc/gccspec.c
===================================================================
--- gcc/gccspec.c	(revision 122345)
+++ gcc/gccspec.c	(working copy)
@@ -30,7 +30,10 @@
 		      const char *const **in_argv ATTRIBUTE_UNUSED,
 		      int *in_added_libraries ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_SHARED_LIBGCC
+  /* Systems which use the NeXT runtime by default should arrange
+     for the shared libgcc to be used when -fgnu-runtime is passed
+     through specs.  */
+#if defined(ENABLE_SHARED_LIBGCC) && ! defined(NEXT_OBJC_RUNTIME)
   int i;
 
   /* The new argument list will be contained in this.  */
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 122345)
+++ gcc/config/darwin.h	(working copy)
@@ -351,7 +351,7 @@
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC						   \
    "%{static-libgcc|static: -lgcc_eh -lgcc;				   \
-      shared-libgcc|fexceptions:					   \
+      shared-libgcc|fexceptions|fgnu-runtime:				   \
        %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)	   \
        %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_s.10.5)	   \
        -lgcc;								   \
============================================================



More information about the Gcc-patches mailing list