This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Magnus Granberg <zorry at gentoo dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>, danielmicay <danielmicay at gmail dot com>
- Date: Mon, 12 Jan 2015 15:53:54 -0800
- Subject: Re: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option
- Authentication-results: sourceware.org; auth=none
- References: <4827012 dot p4mTkPPu1h at laptop1 dot gw dot ume dot nu> <2546517 dot 6r217PbQ20 at laptop1 dot gw dot ume dot nu> <3640063 dot 8rDKLvUbS6 at laptop1 dot gw dot ume dot nu> <1625902 dot vd5h90ZESU at laptop1 dot gw dot ume dot nu> <CAFiYyc36p_JMOHbbDPOYJisRw1cL3gakAHmc1DJLGiS3vD9oUQ at mail dot gmail dot com> <20150112161023 dot GA6392 at gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1501122347110 dot 26937 at digraph dot polyomino dot org dot uk>
On Mon, Jan 12, 2015 at 3:50 PM, Joseph Myers <joseph@codesourcery.com> 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.