From patchwork Sun Aug 5 00:39:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 175147 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 758202C0095 for ; Sun, 5 Aug 2012 10:39:38 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344731979; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=RtlYC0LNKC9MhfoMvru1Fic3MdU=; b=yJ/zi+yAt9NXnLa zLm2HBHnDoql7Ts0fZM2RdD7itB2mp77+2XLOq79nTcOCJDoxktBxtF32XEfxVD2 arGsuOnQXsvw711m8oDE28/ihHrKjBRSFP9U/YU76ovH2d3KJTU8LN0HtbbOo0BF GVgQ1MDLwCHdgf4Ar4NWmS5Hm984= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=hyquDCbyRM4jz/8wyKIC84J2C46QCYxfeRZF8GojpfL+uPySknrHKWf7QErxAL AZ2VLaJ2g5pNDCbmA3LYEPtm78QD7F4nn/gGZIokC9WS0Dap2IyveMZ5e+00BrYS LUNnANHMS0nVrtIH9xNzBqnCJ6GUMCZqxxR6X5HaGQbpQ=; Received: (qmail 17947 invoked by alias); 5 Aug 2012 00:39:35 -0000 Received: (qmail 17939 invoked by uid 22791); 5 Aug 2012 00:39:34 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 05 Aug 2012 00:39:20 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SxosJ-0002RZ-IH from Sandra_Loosemore@mentor.com ; Sat, 04 Aug 2012 17:39:19 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 4 Aug 2012 17:39:19 -0700 Received: from [IPv6:::1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Sat, 4 Aug 2012 17:39:18 -0700 Message-ID: <501DC0B9.6060109@codesourcery.com> Date: Sat, 4 Aug 2012 18:39:21 -0600 From: Sandra Loosemore User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: , Subject: Re: [PATCH, MIPS] diagnose -fpic/-fpie incompatibility with -mno-abicalls References: <501C0D4A.1070906@codesourcery.com> <87pq76lpf0.fsf@talisman.home> In-Reply-To: <87pq76lpf0.fsf@talisman.home> 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 On 08/04/2012 08:09 AM, Richard Sandiford wrote: > Sandra Loosemore writes: >> For all supported MIPS ABIs other than EABI, compiling with >> -fpic/-fPIC/-fpie/-fPIE implicitly requires abicalls support. On Linux >> targets, -mabicalls is the default, but bare-metal targets like >> mips-sde-elf default to -mno-abicalls and naively compiling with -fPIC >> alone doesn't result in working code. (In fact, even "-fPIC -mabicalls" >> doesn't work, because -mabicalls then conflicts with the default for -G, >> and the linker rejects mixing -mabicalls code with -mno-abicalls >> libraries.) > > Yeah. I was tempted to add a message for this a while back, but I think > there was resistance from someone who was managing to generate a form of > PIC with careful use of that combination. If they did, it was by accident > rather than design. > > However, EABI doesn't support PIC at all. (There used to be an > -membedded-pic option, but that's long gone.) So I think this: [snip] > should be: > > if (flag_pic) > { > if (mips_abi == ABI_EABI) > error ("cannot generate position-independent code for %qs", > "-mabi=eabi"); > else if (!TARGET_ABICALLS) > error ("position-independent code requires %qs", "-mabicalls"); > } > > (where flag_pie implies flag_pic). I've removed the -fpic/-fpie thing > to avoid having to decide between printing "-fpic" and "-fPIC" > (or "-fpie" and "-fPIE"). > > OK with that change, if you agree. Yes indeed -- I was dithering on exactly what the error message should say anyway. I've committed the attached version. -Sandra 2012-08-04 Sandra Loosemore Richard Sandiford gcc/ * config/mips/mips.c (mips_option_override): Check -fpic for compatibility with -mabicalls and ABI. gcc/testsuite/ * g++.dg/opt/enum2.C: Require fpic target. * g++.dg/lto/20090303_0.C: Likewise. Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c (revision 190149) +++ gcc/config/mips/mips.c (working copy) @@ -16162,6 +16162,16 @@ mips_option_override (void) target_flags &= ~MASK_ABICALLS; } + /* PIC requires -mabicalls. */ + if (flag_pic) + { + if (mips_abi == ABI_EABI) + error ("cannot generate position-independent code for %qs", + "-mabi=eabi"); + else if (!TARGET_ABICALLS) + error ("position-independent code requires %qs", "-mabicalls"); + } + if (TARGET_ABICALLS_PIC2) /* We need to set flag_pic for executables as well as DSOs because we may reference symbols that are not defined in Index: gcc/testsuite/g++.dg/opt/enum2.C =================================================================== --- gcc/testsuite/g++.dg/opt/enum2.C (revision 190149) +++ gcc/testsuite/g++.dg/opt/enum2.C (working copy) @@ -1,8 +1,8 @@ // PR c++/43680 // Test that we don't make excessively aggressive assumptions about what // values an enum variable can have. +// { dg-do run { target fpic } } // { dg-options "-O2 -fPIC" } -// { dg-do run } extern "C" void abort (); Index: gcc/testsuite/g++.dg/lto/20090303_0.C =================================================================== --- gcc/testsuite/g++.dg/lto/20090303_0.C (revision 190149) +++ gcc/testsuite/g++.dg/lto/20090303_0.C (working copy) @@ -1,4 +1,5 @@ /* { dg-lto-do run } */ +/* { dg-require-effective-target fpic } */ /* { dg-lto-options {{-flto -flto-partition=1to1 -fPIC}} } */ /* { dg-lto-options {{-flto -flto-partition=1to1}} { target sparc*-*-* } } */ /* { dg-suppress-ld-options {-fPIC} } */