diff mbox

[1-3] New configure option to enable Position independent executable as default.

Message ID 2756684.DTPqkWbiRk@laptop1.gw.ume.nu
State New
Headers show

Commit Message

Magnus Granberg Nov. 17, 2013, 9:37 p.m. UTC
lördag 16 november 2013 20.37.58 skrev  Ryan Hill:
> On Wed, 13 Nov 2013 23:28:45 +0100
> 
> Magnus Granberg <zorry@gentoo.org> wrote:
> > Hi
> > This patchset will add a new configure options --enable-default-pie.
> > With the new option enable will make it pass -fPIE and -pie from the gcc
> > and g++ frontend. Have only add the support for two targets but should
> > work on more targes. In configure.ac we add the new option. We can't
> > compile the compiler or the crt stuff with -fPIE it will brake the PCH
> > and the crtbegin and crtend files. The disabling is done in the
> > Makefiles. The needed spec is added to DRIVER_SELF_SPECS. We disable all
> > the profiling test for the linking will fail.Tested on x86_64 linux
> > (Gentoo).
> > 
> > /Magnus Granberg
> 
> Hey Magnus.  Some nits:
......
> > +for C, C++, ObjC, ObjC++, if none of @option{-fno-PIE},
> > @option{-fno-pie},
> > +@option{-fPIC}, @option{-fpic}, @option{-fno-PIC}, @option{-fno-pic},
> > +@option{-nostdlib}, @option{-nostartfiles}, @option{-shared},
> > +@option{-nodefaultlibs}, nor @option{static} are found.
> 
> Looks like nodefaultlibs is missing from PIE_DRIVER_SELF_SPECS or this needs
> to be updated.
> 
> Thanks!

Thankyou for the nits. Have updated the patches with the fixes.
The same changlog should work in my first post about this new option.

>Mike Stump wrote
>Ick.  Would be nice to figure out on what systems one can do this and just do 
>it without the configure option.  Is there some reason that we need an option 
>for it?
It would work well on most *-*-linux* targets but i don't have all the 
hardware for testing and I agre with Ian that it should not be default enable.

/Magnus Granberg

Comments

Magnus Granberg Nov. 19, 2013, 5:36 p.m. UTC | #1
söndag 17 november 2013 22.37.08 skrev  Magnus Granberg:
> lördag 16 november 2013 20.37.58 skrev  Ryan Hill:
> > On Wed, 13 Nov 2013 23:28:45 +0100
> > 
> > Magnus Granberg <zorry@gentoo.org> wrote:
> > > Hi
> > > This patchset will add a new configure options --enable-default-pie.
> > > With the new option enable will make it pass -fPIE and -pie from the gcc
> > > and g++ frontend. Have only add the support for two targets but should
> > > work on more targes. In configure.ac we add the new option. We can't
> > > compile the compiler or the crt stuff with -fPIE it will brake the PCH
> > > and the crtbegin and crtend files. The disabling is done in the
> > > Makefiles. The needed spec is added to DRIVER_SELF_SPECS. We disable all
> > > the profiling test for the linking will fail.Tested on x86_64 linux
> > > (Gentoo).
> > > 
> > > /Magnus Granberg
> > 
> > Hey Magnus.  Some nits:
> ......
> 
> > > +for C, C++, ObjC, ObjC++, if none of @option{-fno-PIE},
> > > @option{-fno-pie},
> > > +@option{-fPIC}, @option{-fpic}, @option{-fno-PIC}, @option{-fno-pic},
> > > +@option{-nostdlib}, @option{-nostartfiles}, @option{-shared},
> > > +@option{-nodefaultlibs}, nor @option{static} are found.
> > 
> > Looks like nodefaultlibs is missing from PIE_DRIVER_SELF_SPECS or this
> > needs to be updated.
> > 
> > Thanks!
> 
> Thankyou for the nits. Have updated the patches with the fixes.
> The same changlog should work in my first post about this new option.
> 
> >Mike Stump wrote
> >Ick.  Would be nice to figure out on what systems one can do this and just
> >do it without the configure option.  Is there some reason that we need an
> >option for it?
> 
> It would work well on most *-*-linux* targets but i don't have all the
> hardware for testing and I agre with Ian that it should not be default
> enable.
> 
> /Magnus Granberg
Can some one review the patches and commit if it look sane?

/Magnus Granberg
diff mbox

Patch

--- a/gcc/doc/install.texi	2013-10-01 19:29:40.000000000 +0200
+++ b/gcc/doc/install.texi	2013-11-17 16:13:20.474144921 +0100
@@ -1421,6 +1421,10 @@  do a @samp{make -C gcc gnatlib_and_tools
 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*.
+
 @item --disable-libquadmath
 Specify that the GCC quad-precision math library should not be built.
 On some systems, the library is required to be linkable when building
--- a/gcc/doc/invoke.texi	2013-10-03 19:13:50.000000000 +0200
+++ b/gcc/doc/invoke.texi	2013-11-17 21:30:02.784220111 +0100
@@ -10134,6 +10134,12 @@  For predictable results, you must also s
 used for compilation (@option{-fpie}, @option{-fPIE},
 or model suboptions) when you specify this linker option.
 
+NOTE: With configure --enable-default-pie this option is enabled by default
+for C, C++, ObjC, ObjC++, if none of @option{-fno-PIE}, @option{-fno-pie},
+@option{-fPIC}, @option{-fpic}, @option{-fno-PIC}, @option{-fno-pic},
+@option{-nostdlib}, @option{-nostartfiles}, @option{-shared},
+@option{-nodefaultlibs}, nor @option{static} are found.
+
 @item -rdynamic
 @opindex rdynamic
 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
@@ -21371,6 +21377,12 @@  used during linking.
 @code{__pie__} and @code{__PIE__}.  The macros have the value 1
 for @option{-fpie} and 2 for @option{-fPIE}.
 
+NOTE: With configure --enable-default-pie this option is enabled by default
+for C, C++, ObjC, ObjC++, if none of @option{-fno-PIE}, @option{-fno-pie},
+@option{-fPIC}, @option{-fpic}, @option{-fno-PIC}, @option{-fno-pic},
+@option{-nostdlib}, @option{-nostartfiles}, @option{-shared},
+@option{-nodefaultlibs}, nor @option{static} are found.
+
 @item -fno-jump-tables
 @opindex fno-jump-tables
 Do not use jump tables for switch statements even where it would be