public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	Magnus Granberg <zorry@gentoo.org>,
		GCC Patches <gcc-patches@gcc.gnu.org>,
	danielmicay <danielmicay@gmail.com>
Subject: PING^4: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option
Date: Tue, 14 Apr 2015 19:21:00 -0000	[thread overview]
Message-ID: <CAMe9rOr=6h3cjgQs+7hmG1-Pz-t3Wvty+Zm487KPDk3oeNcfXA@mail.gmail.com> (raw)

PING.

On Fri, Mar 6, 2015 at 9:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> PING.  I am enclosing the patch here for review.
>
> On Wed, Feb 11, 2015 at 8:47 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> PING.
>>
>> On Wed, Jan 28, 2015 at 8:05 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> PING.
>>>
>>> On Tue, Jan 13, 2015 at 3:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Tue, Jan 13, 2015 at 5:03 AM, H.J. Lu <hjl.tools@gmail.com> 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  <zorry@gentoo.org>
>>>>>             H.J. Lu  <hongjiu.lu@intel.com>
>>>>>
>>>>>         * 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  <hongjiu.lu@intel.com>
>>>>>
>>>>>         * gcc-interface/Makefile.in (TOOLS_LIBS): Add @NO_PIE_FLAG@.
>>>>>
>>>>> libgcc/
>>>>>
>>>>> 2015-01-12  H.J. Lu  <hongjiu.lu@intel.com>
>>>>>
>>>>>         * 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.

                 reply	other threads:[~2015-04-14 19:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOr=6h3cjgQs+7hmG1-Pz-t3Wvty+Zm487KPDk3oeNcfXA@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=danielmicay@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=richard.guenther@gmail.com \
    --cc=zorry@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).