From patchwork Wed Jan 5 13:15:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 77592 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 E79BFB6F2B for ; Thu, 6 Jan 2011 00:15:40 +1100 (EST) Received: (qmail 15894 invoked by alias); 5 Jan 2011 13:15:36 -0000 Received: (qmail 15858 invoked by uid 22791); 5 Jan 2011 13:15:32 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Jan 2011 13:15:27 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 9EC5A9AC79B; Wed, 5 Jan 2011 14:15:25 +0100 (CET) Date: Wed, 5 Jan 2011 14:15:25 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de, tglek@mozilla.com Subject: Fix -fPIC issue with GNU LD and LTO Message-ID: <20110105131525.GC24016@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 Hi, this patch enables us to get past failure with LTO mozilla build using GNU LD. Mozilla invoke link as /abuild/jh/trunk-install/bin/gcc -O3 -flto -flto-partition=none -fuse-linker-plugin -shared -Wl,-soname -Wl,libplds4.so -o libplds4.so ./plarena.o ./plhash.o ./plvrsion.o -L/abuild/jh/build-mozilla-new7/dist/lib -lnspr4 that leads us to build PC32 relocations to external symbols. This is because flag_shlib is not set. Normally -fPIC imply flag_shlib via finalize_options, but since -fPIC is issued only later due to lto_reissue_options, we never get around setting it. The following patch fixes it by adding logic to lto_reissue_options. Hacky, but the whole thing is a hack and I can't think of anything better. OK? Bootstrapped/regtested x86_64-linux. PR lto/45375 * lto-opt.c (lto_reissue_options): Set flag_shlib. Index: lto-opts.c =================================================================== --- lto-opts.c (revision 168506) +++ lto-opts.c (working copy) @@ -420,5 +420,9 @@ gcc_unreachable (); } + /* Flag_shlib is usually set by finish_options, but we are issing flag_pic + too late. */ + if (flag_pic && !flag_pie) + flag_shlib = 1; VEC_free (opt_t, heap, opts); }