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. -- Joseph S. Myers jos...@codesourcery.com