From patchwork Mon Nov 10 20:26:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Granberg X-Patchwork-Id: 409075 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EDA4714012C for ; Tue, 11 Nov 2014 07:28:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Uu5 3krlIaa7o+Pxv3/x9dgX8vI8rPYR25ENZ3HPNEsXN4/zw0g76FOw24KNKOu4musr OOVM2RKw3I+1d1/yfUjIXDRq8/EosIyI+a9ScVshDCA+Ehgw3rdWP13rcEaKIjBr 9pmz8LUP4sKs+HWCa0NVLKuWXcwODjzddbqAjqqw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=default; bh=+LXG5sHrx soh4Wmyk5CEcQqKHQU=; b=mNp/PZHzoEDQjf1GFY8MOAfP332Mschw1czR+fnwz cK+yMxsbq+ZCwdGvdLFTDIgbA3pRnyi8OvvyEQy9oOh1k2pEAQidQ6RFDSaxZemy nZIBInsca+FVRPp5YbvmFpTPltukep+wP52E57qUQOWF0IZ6N0dMICdGkRGURjP9 uQ= Received: (qmail 28766 invoked by alias); 10 Nov 2014 20:28:18 -0000 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 Received: (qmail 28755 invoked by uid 89); 10 Nov 2014 20:28:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 10 Nov 2014 20:28:14 +0000 Received: from laptop1.gw.ume.nu (ip1-67.bon.riksnet.se [77.110.8.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: zorry) by smtp.gentoo.org (Postfix) with ESMTPSA id DE7E5340445 for ; Mon, 10 Nov 2014 20:28:10 +0000 (UTC) From: Magnus Granberg To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH][1-3] New configure options that make the compiler use -fPIE and -pie as default option Date: Mon, 10 Nov 2014 21:26:39 +0100 Message-ID: <2546517.6r217PbQ20@laptop1.gw.ume.nu> User-Agent: KMail/4.13.2 (Linux/3.13.9-hardened; KDE/4.13.2; x86_64; ; ) In-Reply-To: References: <4827012.p4mTkPPu1h@laptop1.gw.ume.nu> MIME-Version: 1.0 X-IsSubscribed: yes fredag 01 augusti 2014 10.52.27 skrev Rainer Orth: > Hi Magnus, > > a couple of comments, mostly nits. > > > 2014-07-31 Magnus Granberg > > > > /gcc > > * config/gnu-user.h: Define PIE_DRIVER_SELF_SPECS for PIE > > as default and GNU_DRIVER_SELF_SPECS. > > * config/i386/gnu-user-common.h: Define DRIVER_SELF_SPECS > > * configure.ac: Add new option that enable PIE as default. > > * configure, config.in: Rebuild. > > * Makefile.in: Disable PIE when building the compiler. > > * doc/install.texi: Add the new configure option default PIE. > > * doc/invoke.texi: Add note for the new configure option default PIE. > > Many of those entries are mis-formatted. See other examples and the GNU > Coding Standards for details. E.g. the first would be > > * config/gnu-user.h (PIE_DRIVER_SELF_SPECS): Define. > > In general, you need to mention which macro, variable, manual section > you change. Emacs' add-change-log-entry does the basics for you. > Besides, you only state what changed, not why. > > Apart from that, I don't think defining PIE_DRIVER_SELF_SPECS in > gnu-user.h is a good idea. This way, every other target supporting the > option would have to duplicate that stuff. > > * testsuite/gcc/default-pie.c: New test for new configure option > --enale-default-pie > > gcc/testsuite has its own ChangeLog file. Typo for --enale-... > > * testsuite/gcc.dg/other/anon5.C: Add skip test as it fail to link > on effective_target default_pie. > > should be > > * g++.dg/other/anon5.C: Skip if default_pie. > > No explanations in ChangeLog entries; they belong into the code. > Besides, you had the first dir component wrong. Again, Emacs does this > for you. > > * testsuite/lib/target-supports.exp (check_profiling_available): > We can't use profiling on effective target default_pie. > (check_effective_target_pie): Add check_effective_target_default_pie. > > Wrong: should be > > * lib/target-supports.exp (check_effective_target_default_pie): > New proc. > > The new default_pic effective-target keyword needs to be documented in > doc/sourcebuild.texi. > > --- a/gcc/testsuite/gcc.dg/default-pie.c 2013-11-09 21:07:16.741479728 +0100 > +++ b/gcc/testsuite/gcc.dg/default-pie.c 2013-11-09 21:05:07.801479218 > +0100 @@ -0,0 +1,12 @@ > +/* { dg-do compile { target *-*-linux* *-*-gnu* } } */ > +/* { dg-require-effective-target default_pie } */ > > Why restrict to Linux, GNU? default_pie should be enough once other > targets add this. > > --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c 2012-03-14 > 17:33:37.000000000 +0100 +++ > b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c 2014-07-29 > 00:55:17.421086416 +0200 @@ -2,6 +2,9 @@ > /* Skipped on MIPS GNU/Linux target because __PIC__ can be > defined for executables as well as shared libraries. */ > /* { dg-skip-if "" { *-*-darwin* hppa*64*-*-* mips*-*-linux* *-*-mingw* } { > "*" } { "" } } */ +/* Skipped on default_pie targets because __PIC__ is > + defined for executables. */ > +/* { dg-skip-if "" { default_pie } { "*" } { "" } } */ > > Emit those default args, they're unnecessary. Also in g++.dg/other/anon5.C. > > --- a/gcc/testsuite/g++.dg/other/anon5.C 2012-11-10 15:34:42.000000000 +0100 > +++ b/gcc/testsuite/g++.dg/other/anon5.C 2013-11-09 14:49:52.281390127 > +0100 @@ -1,5 +1,6 @@ > // PR c++/34094 > // { dg-do link { target { ! { *-*-darwin* *-*-hpux* *-*-solaris2.* } } } } > +// { dg-skip-if "" { default_pie } { "*" } { "" } } > > The first arg to dg-skip-if should explain why you're skipping the test. > > --- a/gcc/testsuite/lib/target-supports.exp 2013-10-01 11:18:30.000000000 > +0200 +++ b/gcc/testsuite/lib/target-supports.exp 2013-10-25 > 22:01:46.743388469 +0200 @@ -474,6 +474,11 @@ proc > check_profiling_available { test_wh > } > } > > + # Profiling don't work with default -fPIE -pie. > > Grammar: "doesn't work". > > +# Return 1 if -pie, -fPIE are default enable, 0 otherwise. > + > +proc check_effective_target_default_pie { } { > > Hard to understand, perhaps > > # Return 1 if -pie -fPIE are enabled by default, 0 otherwise. > > --- a/gcc/doc/invoke.texi 2013-10-03 19:13:50.000000000 +0200 > +++ b/gcc/doc/invoke.texi 2013-11-17 21:30:02.784220111 +0100 > @@ -10535,6 +10535,12 @@ For predictable results, you must also s > used for compilation (@option{-fpie}, @option{-fPIE}, > or model suboptions) when you specify this linker option. > > +NOTE: With configure --enable-default-pie this option is enabled by default > > With the @option{--enable-default-pie} configure option, ... > > +for C, C++, ObjC, ObjC++, if none of @option{-fno-PIE}, @option{-fno-pie}, > +@option{-fPIC}, @option{-fpic}, @option{-fno-PIC}, @option{-fno-pic}, > +@option{-nostdlib}, @option{-nostartfiles}, @option{-shared}, > +@option{-nodefaultlibs}, nor @option{static} are found. > > @option{-static}. > > Rainer Thanks Rainer for the nits and comments. Have updated the patches and Changelogs. But i still use PIE_DRIVER_SELF_SPECS, do you have a ide where move it so i don't need to duplicate that stuff or how to do it? Magnus G 2014-11-10 Magnus Granberg /gcc * config/gnu-user.h (PIE_DRIVER_SELF_SPECS) and (GNU_DRIVER_SELF_SPECS): Define. * config/i386/gnu-user-common.h (DRIVER_SELF_SPECS): Define * configure.ac: Add new option. * configure, config.in: Rebuild. * Makefile.in (ALL_CFLAGS) and (ALL_CXXFLAGS): Disable PIE. * doc/install.texi: New configure option. * doc/invoke.texi: Add note to PIE. * doc/sourcebuild.texi: New effective target. gcc/testsuite * gcc/default-pie.c: New test * gcc.dg/tree-ssa/ssa-store-ccp-3.c: Skip if default_pie * g++.dg/other/anon5.C: Skip if default_pie * lib/target-supports.exp (check_effective_target_default_pie): New proc. /libgcc * Makefile.in (CRTSTUFF_CFLAGS): Disable PIE. --- a/gcc/testsuite/gcc.dg/default-pie.c 2013-11-09 21:07:16.741479728 +0100 +++ b/gcc/testsuite/gcc.dg/default-pie.c 2013-11-09 21:05:07.801479218 +0100 @@ -0,0 +1,11 @@ +/* { dg-require-effective-target default_pie } */ +/* { dg-options "-O2" } */ +int foo (void); + +int +main (void) +{ + return foo (); +} + +/* { dg-final { scan-assembler "foo@PLT" } } */ --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c 2012-03-14 17:33:37.000000000 +0100 +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c 2014-07-29 00:55:17.421086416 +0200 @@ -2,6 +2,7 @@ /* Skipped on MIPS GNU/Linux target because __PIC__ can be defined for executables as well as shared libraries. */ /* { dg-skip-if "" { *-*-darwin* hppa*64*-*-* mips*-*-linux* *-*-mingw* } { "*" } { "" } } */ +/* { dg-skip-if "" { default_pie } { "*" } { "" } } */ /* { dg-options "-O2 -fno-common -fdump-tree-optimized" } */ const int conststaticvariable; --- a/gcc/testsuite/g++.dg/other/anon5.C 2012-11-10 15:34:42.000000000 +0100 +++ b/gcc/testsuite/g++.dg/other/anon5.C 2013-11-09 14:49:52.281390127 +0100 @@ -1,5 +1,6 @@ // PR c++/34094 // { dg-do link { target { ! { *-*-darwin* *-*-hpux* *-*-solaris2.* } } } } +// { dg-skip-if "" { default_pie } { "*" } { "" } } // { dg-options "-g" } // Ignore additional message on powerpc-ibm-aix // { dg-prune-output "obtain more information" } */ --- a/gcc/testsuite/lib/target-supports.exp 2013-10-01 11:18:30.000000000 +0200 +++ b/gcc/testsuite/lib/target-supports.exp 2013-10-25 22:01:46.743388469 +0200 @@ -474,6 +474,11 @@ proc check_profiling_available { test_wh } } + # Profiling doesn't work with default -fPIE -pie. + if { [check_effective_target_default_pie] } { + return 0 + } + # Support for -p on solaris2 relies on mcrt1.o which comes with the # vendor compiler. We cannot reliably predict the directory where the # vendor compiler (and thus mcrt1.o) is installed so we can't @@ -856,6 +856,14 @@ proc check_effective_target_pie { } { return 0 } +# Return 1 if -pie, -fPIE are enable by default, 0 otherwise. + +proc check_effective_target_default_pie { } { + global ENABLE_DEFAULT_PIE + return [info exists ENABLE_DEFAULT_PIE] + return 0 +} + # Return true if the target supports -mpaired-single (as used on MIPS). proc check_effective_target_mpaired_single { } {