This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: PING^3: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option


On Sat, May 30, 2015 at 8:10 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> +# Check if -fno-PIE works.
>> +AC_CACHE_CHECK([for -fno-PIE option],
>> +  [gcc_cv_c_no_fpie],
>> +  [saved_CFLAGS="$CFLAGS"
>> +   CFLAGS="$CFLAGS -fno-PIE"
>> +   AC_COMPILE_IFELSE([int main(void) {return 0;}],
>> +     [gcc_cv_c_no_fpie=yes],
>> +     [gcc_cv_c_no_fpie=no])
>> +   CFLAGS="$saved_CFLAGS"])
>> +if test "$gcc_cv_c_no_fpie" = "yes"; then
>> +  NO_PIE_CFLAGS="-fno-PIE"
>> +fi
>> +AC_SUBST([NO_PIE_CFLAGS])
>> +
>
> That doesn't work:
>
> configure:28726: checking for -fno-PIE option
> configure:28737: g++ -c -g   conftest.cpp >&5
> configure:28737: $? = 0
> configure:28745: result: yes
>
>> +# Check if -no-pie works.
>> +AC_CACHE_CHECK([for -no-pie option],
>> +  [gcc_cv_no_pie],
>> +  [saved_LDFLAGS="$LDFLAGS"
>> +   LDFLAGS="$LDFLAGS -no-pie"
>> +   AC_LINK_IFELSE([int main(void) {return 0;}],
>> +     [gcc_cv_no_pie=yes],
>> +     [gcc_cv_no_pie=no])
>> +   LDFLAGS="$saved_LDFLAGS"])
>> +if test "$gcc_cv_no_pie" = "yes"; then
>> +  NO_PIE_FLAG="-no-pie"
>> +fi
>> +AC_SUBST([NO_PIE_FLAG])
>> +
>
> That doesn't work with gcc 4.3:
>
> configure:28753: checking for -no-pie option
> configure:28764: g++ -std=c++98 -o conftest -g     -no-pie conftest.cpp  >&5
> g++: unrecognized option '-no-pie'
> configure:28764: $? = 0
> configure:28773: result: yes
>

Starting GCC 4.6, the unrecognized option became an error.
Before 4.6, it was ignored.  Does it cause any problems for
bootstrap?

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]