From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14347 invoked by alias); 12 Jan 2015 23:53:58 -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 14327 invoked by uid 89); 12 Jan 2015 23:53:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f173.google.com Received: from mail-ob0-f173.google.com (HELO mail-ob0-f173.google.com) (209.85.214.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 Jan 2015 23:53:56 +0000 Received: by mail-ob0-f173.google.com with SMTP id nt9so1432600obb.4 for ; Mon, 12 Jan 2015 15:53:54 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.52.132 with SMTP id t4mr19008595oeo.11.1421106834190; Mon, 12 Jan 2015 15:53:54 -0800 (PST) Received: by 10.76.185.7 with HTTP; Mon, 12 Jan 2015 15:53:54 -0800 (PST) In-Reply-To: References: <4827012.p4mTkPPu1h@laptop1.gw.ume.nu> <2546517.6r217PbQ20@laptop1.gw.ume.nu> <3640063.8rDKLvUbS6@laptop1.gw.ume.nu> <1625902.vd5h90ZESU@laptop1.gw.ume.nu> <20150112161023.GA6392@gmail.com> Date: Tue, 13 Jan 2015 00:31:00 -0000 Message-ID: Subject: Re: [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-01/txt/msg00782.txt.bz2 On Mon, Jan 12, 2015 at 3:50 PM, 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 will make the change. Can someone test it on non-x86 Linux? > 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. > I will remove them. Thanks. -- H.J.