From patchwork Mon Nov 21 16:40:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 126843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0029BB7209 for ; Tue, 22 Nov 2011 03:41:18 +1100 (EST) Received: (qmail 26184 invoked by alias); 21 Nov 2011 16:41:12 -0000 Received: (qmail 26172 invoked by uid 22791); 21 Nov 2011 16:41:10 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_BJ, TW_LG, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Nov 2011 16:40:31 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 44B4661F; Mon, 21 Nov 2011 17:40:30 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jAk4K3LNl17y; Mon, 21 Nov 2011 17:40:26 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id B7E1961E; Mon, 21 Nov 2011 17:40:26 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id pALGeQVe015312; Mon, 21 Nov 2011 17:40:26 +0100 (MET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Michael Matz Subject: Support enforcing use of libgcc_s even with LINK_EH_SPEC Date: Mon, 21 Nov 2011 17:40:26 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org For the last two weeks, testsuite results on Solaris 11/x86 with gld 2.21.1 have been terrible, which hundreds of link failures. One example is spawn /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/xgcc -B/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/ /vol/gcc/src/hg/trunk/local/libffi/testsuite/libffi.call/closure_fn0.c -O0 -W -Wall -I/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/include -I/vol/gcc/src/hg/trunk/local/libffi/testsuite/../include -I/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/include/.. -L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/.libs -L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libstdc++-v3/src/.libs -lffi -lm -o ./closure_fn0.exe /vol/gcc/bin/gld-2.21.1: .compiler exited with status 1 output is: /vol/gcc/bin/gld-2.21.1: . FAIL: libffi.call/closure_fn0.c -O0 -W -Wall (test for excess errors) Excess errors: /vol/gcc/bin/gld-2.21.1: . WARNING: libffi.call/closure_fn0.c -O0 -W -Wall compilation failed to produce executable Executing this manually gives: /vol/gcc/bin/gld-2.21.1: ./closure_fn0.exe: hidden symbol `__gcc_personality_v0' in /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/libgcc_eh.a(unwind-c.o) is referenced by DSO /vol/gcc/bin/gld-2.21.1: final link failed: Bad value collect2: error: ld returned 1 exit status The message could certainly be improved here! (It turns out the DSO in question is libffi.so.) I've still to investigate where this bad pruning stems from, but the problem boils down to the following: since this patch 2011-11-08 Michael Matz * gengtype.c (write_field_root): Avoid out-of-scope access of newv. * tree-stdarg.c (execute_optimize_stdarg): Accept clobbers. [...] several of the target libraries developed references to __gcc_personality_v0, which weren't there before. The executable is linked like this: /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/collect2 --eh-frame-hdr -V -m elf_i386_sol2 -Y P,/usr/ccs/lib:/lib:/usr/lib -Qy -o ./closure_fn0.exe /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/values-Xa.o /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/crtbegin.o -L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/.libs -L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libstdc++-v3/src/.libs -L/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc closure_fn0.o -lffi -lm -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/crtend.o /usr/lib/crtn.o i.e. only with libgcc_eh.a, where __gcc_personality_v0 is hidden. The problem is that (unlike with ld), libffi.so isn't linked with libgcc_s.so.1 because gcc.c (init_spec) decides that if LINK_EH_SPEC is defined, this mustn't/needn't be done. I've no idea why this should be so, but hacked around it by forcing to always use libgcc_s with -shared as in the patch below. This brought testsuite results with gld much more in line with Sun ld results, but most likely isn't appropriate, or at the very least needs the FIXME comment filled in and documentation in tm.texi. One could of course also link all affected target libraries with an explicit -shared-libgcc (as is already done for e.g. libobjc and libstdc++). Suggestions? Rainer 2011-11-20 Rainer Orth * gcc.c (init_gcc_specs) [USE_SHARED_LIBGCC_FOR_EH]: Always use libgcc_s. * config/sol2.h [USE_GLD] (USE_SHARED_LIBGCC_FOR_EH): Define. # HG changeset patch # Parent 0f811d11987fd90895cf6fda7698d876e59f39a5 Support enforcing use of libgcc_s even with LINK_EH_SPEC diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -182,6 +182,8 @@ along with GCC; see the file COPYING3. --eh-frame-hdr to create the required .eh_frame_hdr sections. */ #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR) #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +/* Always use libgcc_s. FIXME: Why? */ +#define USE_SHARED_LIBGCC_FOR_EH 1 #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */ #endif diff --git a/gcc/gcc.c b/gcc/gcc.c --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1291,7 +1291,7 @@ init_gcc_specs (struct obstack *obstack, "%{!shared-libgcc:", static_name, " ", eh_name, "}" "%{shared-libgcc:", shared_name, " ", static_name, "}" "}" -#ifdef LINK_EH_SPEC +#if defined(LINK_EH_SPEC) && !USE_SHARED_LIBGCC_FOR_EH "%{shared:" "%{shared-libgcc:", shared_name, "}" "%{!shared-libgcc:", static_name, "}"