Patchwork [build,objc] Link libobjc*.la with -shared-libgcc

login
register
mail settings
Submitter Rainer Orth
Date Dec. 22, 2010, 3:15 p.m.
Message ID <ydd4oa5ltxz.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/76420/
State New
Headers show

Comments

Rainer Orth - Dec. 22, 2010, 3:15 p.m.
While developing the patch to use dl_iterate_phdr in the libgcc unwinder
on Solaris 11

	Use dl_iterate_phdr in Solaris 11+ unwinder
        http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02770.html
        http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00978.html
        http://gcc.gnu.org/ml/gcc-patches/2010-12/msg01690.html

I noticed that a couple of objc.dg tests were failing when using GNU ld:

+FAIL: objc.dg/lto/trivial-1 objc_lto_trivial-1_0.o-objc_lto_trivial-1_0.o link, -O0 -fwhopr -fgnu-runtime
+UNRESOLVED: objc.dg/lto/trivial-1 objc_lto_trivial-1_0.o-objc_lto_trivial-1_0.o execute -O0 -fwhopr -fgnu-runtime

/vol/gcc/bin/gld-2.20.51: objc-dg-lto-trivial-1-01: hidden symbol `__gcc_personality_v0' in /vol/gcc/obj/gcc-4.6.0-20101029/11-gcc-gas-gld-cvs/gcc/libgcc_eh.a(unwind-c.o) is referenced by DSO
/vol/gcc/bin/gld-2.20.51: final link failed: Nonrepresentable section on output

While the problem is gone when using --as-needed (via USE_LD_AS_NEEDED),
I cannot do this since it causes any trivial problem to be linked with
libgcc_s.so.1, which isn't right.  As mentioned in the final link above,
I've filed a binutils PR for that, but haven't yet received any
response.

I've I check the resulting libobjc.so.2 with ldd -d, I find

$ ldd -d libobjc.so.2
        libc.so.1 =>     /lib/libc.so.1
        symbol not found: __gcc_personality_v0          (../../../i386-pc-solari
s2.11/libobjc/.libs/libobjc.so.2)
        libm.so.2 =>     /lib/libm.so.2

that it has an undefined reference to __gcc_personality_v0, i.e. should
be linked with the shared libgcc_s.so.1.  Given that libobjc.so does
exception handling, the description of -shared-libgcc suggests that
using that option is the right thing to do.  The following patch does
exactly that.

The issue does not occur with Sun ld, since -shared results in always
linking with -lgcc_s:

      %{shared:-lgcc_s}}}

while with gld, the libgcc spec looks like this:

      %{shared:%{shared-libgcc:-lgcc_s}%{!shared-libgcc:-lgcc}}}}

As described in the third link, 6 bootstraps (i386 and sparc, sun ld
with as, gas, gld with gas) are currently running.  Ok for mainline if
they all pass?

Thanks.
	Rainer


2010-12-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* Makefile.in (libobjc$(libsuffix).la): Link with -shared-libgcc.
	(libobjc_gc$(libsuffix).la): Likewise.
Andrew Pinski - Dec. 22, 2010, 9:13 p.m.
On Wed, Dec 22, 2010 at 7:15 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
> As described in the third link, 6 bootstraps (i386 and sparc, sun ld
> with as, gas, gld with gas) are currently running.  Ok for mainline if
> they all pass?
>
> Thanks.
>        Rainer
>
>
> 2010-12-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>        * Makefile.in (libobjc$(libsuffix).la): Link with -shared-libgcc.
>        (libobjc_gc$(libsuffix).la): Likewise.

Yes this is ok.

Thanks,
Andrew Pinski

Patch

diff -r d0a13ed0b7c5 libobjc/Makefile.in
--- a/libobjc/Makefile.in	Wed Dec 22 11:58:53 2010 +0100
+++ b/libobjc/Makefile.in	Wed Dec 22 12:02:21 2010 +0100
@@ -1,6 +1,6 @@ 
 # Makefile for GNU Objective C runtime library.
 # Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -325,13 +325,13 @@ 
 
 libobjc$(libsuffix).la: $(OBJS)
 	$(LIBTOOL_LINK) $(CC) -o $@ $(OBJS) \
-		-rpath $(toolexeclibdir) \
+		-shared-libgcc -rpath $(toolexeclibdir) \
 		-version-info $(LIBOBJC_VERSION) $(extra_ldflags_libobjc) \
 		$(LTLDFLAGS)
 
 libobjc_gc$(libsuffix).la: $(OBJS_GC)
 	$(LIBTOOL_LINK) $(CC) -o $@ $(OBJS_GC) $(OBJC_BOEHM_GC_LIBS) \
-		-rpath $(toolexeclibdir) \
+		-shared-libgcc -rpath $(toolexeclibdir) \
 		-version-info $(LIBOBJC_GC_VERSION) $(extra_ldflags_libobjc) \
 		$(LTLDFLAGS)