From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43994 invoked by alias); 14 Apr 2015 19:21:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 43984 invoked by uid 89); 14 Apr 2015 19:21:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oi0-f52.google.com Received: from mail-oi0-f52.google.com (HELO mail-oi0-f52.google.com) (209.85.218.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 14 Apr 2015 19:21:53 +0000 Received: by oica37 with SMTP id a37so9312431oic.0 for ; Tue, 14 Apr 2015 12:21:51 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.56.196 with SMTP id c4mr17935293obq.26.1429039311289; Tue, 14 Apr 2015 12:21:51 -0700 (PDT) Received: by 10.76.54.14 with HTTP; Tue, 14 Apr 2015 12:21:51 -0700 (PDT) Date: Tue, 14 Apr 2015 19:21:00 -0000 Message-ID: Subject: PING^4: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option From: "H.J. Lu" To: Joseph Myers Cc: Richard Biener , Magnus Granberg , GCC Patches , danielmicay Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00709.txt.bz2 PING. On Fri, Mar 6, 2015 at 9:31 AM, H.J. Lu wrote: > PING. I am enclosing the patch here for review. > > On Wed, Feb 11, 2015 at 8:47 AM, H.J. Lu wrote: >> PING. >> >> On Wed, Jan 28, 2015 at 8:05 AM, H.J. Lu wrote: >>> PING. >>> >>> On Tue, Jan 13, 2015 at 3:25 PM, H.J. Lu wrote: >>>> On Tue, Jan 13, 2015 at 5:03 AM, H.J. Lu wrote: >>>>> On Mon, Jan 12, 2015 at 11:50:41PM +0000, Joseph Myers wrote: >>>>>> On Mon, 12 Jan 2015, H.J. Lu wrote: >>>>>> >>>>>> > +if test x$enable_default_pie = xyes; then >>>>>> > + AC_MSG_CHECKING(if $target supports default PIE) >>>>>> > + enable_default_pie=no >>>>>> > + case $target in >>>>>> > + i?86*-*-linux* | x86_64*-*-linux*) >>>>>> > + saved_LDFLAGS="$LDFLAGS" >>>>>> > + saved_CFLAGS="$CFLAGS" >>>>>> > + CFLAGS="$CFLAGS -fPIE" >>>>>> > + LDFLAGS="$LDFLAGS -fPIE -pie" >>>>>> > + AC_TRY_LINK(,,[enable_default_pie=yes],) >>>>>> > + LDFLAGS="$saved_LDFLAGS" >>>>>> > + CFLAGS="$saved_CFLAGS" >>>>>> > + ;; >>>>>> > + *) >>>>>> > + ;; >>>>>> > + esac >>>>>> >>>>>> There should not be any such hardcoding of targets here without concrete >>>>>> evidence that the targets for which this sets enable_default_pie=no really >>>>>> cannot support PIE. In particular, there is no reason at all for this to >>>>>> be architecture-specific; all GNU/Linux architectures should support PIE. >>>>>> >>>>>> I believe AC_TRY_LINK here will test for the host, whereas what you want >>>>>> to know is what's supported for the target (but it's not possible to run >>>>>> link tests for the target at this point; the compiler for the target >>>>>> hasn't even been built). >>>>>> >>>>>> So: just presume that if the user passes --enable-default-pie then they >>>>>> know what they are doing, and don't try to override their choice. >>>>>> >>>>>> > diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi >>>>>> > index c9e3bf1..89fc305 100644 >>>>>> > --- a/gcc/doc/install.texi >>>>>> > +++ b/gcc/doc/install.texi >>>>>> > @@ -1583,6 +1583,10 @@ not be built. >>>>>> > Specify that the run-time libraries for stack smashing protection >>>>>> > should not be built. >>>>>> > >>>>>> > +@item --enable-default-pie >>>>>> > +Turn on @option{-fPIE} and @option{-pie} by default if supported. >>>>>> > +Currently supported targets are i?86-*-linux* and x86-64-*-linux*. >>>>>> >>>>>> The "if supported" and target list can then be removed here. >>>>>> >>>>> >>>>> Here is the updated patch. To support --enable-default-pie, each target >>>>> must update STARTFILE_SPEC to support PIE_SPEC and NO_PIE_SPEC. I can >>>>> provide STARTFILE_SPEC patch if needed. >>>>> >>>>> Thanks. >>>>> >>>>> >>>>> H.J. >>>>> --- >>>>> gcc/ >>>>> >>>>> 2015-01-12 Magnus Granberg >>>>> H.J. Lu >>>>> >>>>> * Makefile.in (COMPILER): Add @NO_PIE_CFLAGS@. >>>>> (LINKER): Add @NO_PIE_FLAG@. >>>>> (libgcc.mvars): Set NO_PIE_CFLAGS to -fno-PIE for >>>>> --enable-default-pie. >>>>> * common.opt (fPIE): Initialize to -1. >>>>> (fpie): Likewise. >>>>> (static): Add "RejectNegative Negative(shared)". >>>>> (no-pie): New option. >>>>> (pie): Replace "Negative(shared)" with "Negative(no-pie)". >>>>> * configure.ac: Add --enable-default-pie. >>>>> (NO_PIE_CFLAGS): New. Check if -fno-PIE works. AC_SUBST. >>>>> (NO_PIE_FLAG): New. Check if -no-pie works. AC_SUBST. >>>>> * defaults.h (DEFAULT_FLAG_PIE): New. Default PIE to -fPIE. >>>>> * gcc.c (NO_PIE_SPEC): New. >>>>> (PIE_SPEC): Likewise. >>>>> (LD_PIE_SPEC): Likewise. >>>>> (LINK_PIE_SPEC): Handle -no-pie. Use PIE_SPEC and LD_PIE_SPEC. >>>>> * opts.c (DEFAULT_FLAG_PIE): New. Set to 0 if ENABLE_DEFAULT_PIE >>>>> is undefined. >>>>> (finish_options): Update opts->x_flag_pie if it is -1. >>>>> * config/gnu-user.h (FVTABLE_VERIFY_SPEC): New. >>>>> (GNU_USER_TARGET_STARTFILE_SPEC): Use FVTABLE_VERIFY_SPEC. Use >>>>> NO_PIE_SPEC and NO_PIE_SPEC if ENABLE_DEFAULT_PIE is defined. >>>>> (GNU_USER_TARGET_STARTFILE_SPEC): Use FVTABLE_VERIFY_SPEC. >>>>> * doc/install.texi: Document --enable-default-pie. >>>>> * doc/invoke.texi: Document -no-pie. >>>>> * config.in: Regenerated. >>>>> * configure: Likewise. >>>>> >>>>> gcc/ada/ >>>>> >>>>> 2015-01-12 H.J. Lu >>>>> >>>>> * gcc-interface/Makefile.in (TOOLS_LIBS): Add @NO_PIE_FLAG@. >>>>> >>>>> libgcc/ >>>>> >>>>> 2015-01-12 H.J. Lu >>>>> >>>>> * Makefile.in (CRTSTUFF_CFLAGS): Add $(NO_PIE_CFLAGS). >>>>> >>>> >>>> This is the updated patch. I fixed the -r regression. LTO tests >>>> pass now. >>>> >>>> -- >>>> H.J. >>> >>> >>> >>> -- >>> H.J. >> >> >> >> -- >> H.J. > > > > -- > H.J. -- H.J.