| Submitter | Jack Howarth |
|---|---|
| Date | Dec. 3, 2011, 3:25 p.m. |
| Message ID | <20111203152523.GA9331@bromo.med.uc.edu> |
| Download | mbox | patch |
| Permalink | /patch/129086/ |
| State | New |
| Headers | show |
Comments
On Dec 3, 2011, at 7:25 AM, Jack Howarth wrote: > FSF gcc currently doesn't handle -fno-pie and friends properly under Lion. > The darwin11 linker now defaults to -pie > Okay for gcc trunk and backports to gcc-4_5-branch/gcc-4_6-branch? Ok.
On Sat, Dec 03, 2011 at 10:45:18PM -0800, Mike Stump wrote: > On Dec 3, 2011, at 7:25 AM, Jack Howarth wrote: > > FSF gcc currently doesn't handle -fno-pie and friends properly under Lion. > > The darwin11 linker now defaults to -pie > > > Okay for gcc trunk and backports to gcc-4_5-branch/gcc-4_6-branch? > > Ok. Mike, Thanks for the commit. This leaves us with the boehm-gc testsuite failures... FAIL: boehm-gc.c/gctest.c -O2 execution test FAIL: boehm-gc.c/leak_test.c -O2 execution test FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test at -m32/-m64 on x86_64-apple-darwin11 due to the -pie linker default. Iain had wanted to leave these in place to encourage boehm-gc to be fixed but I doubt that is a realistic goal in the near/middle term. Perhaps we could patch boehm-gc/testsuite/lib/boehm-gc.exp to pass -fno-pie on darwin (now that it is functional)? Jack
On Dec 4, 2011, at 9:09 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote: > On Sat, Dec 03, 2011 at 10:45:18PM -0800, Mike Stump wrote: >> On Dec 3, 2011, at 7:25 AM, Jack Howarth wrote: >>> FSF gcc currently doesn't handle -fno-pie and friends properly under Lion. >>> The darwin11 linker now defaults to -pie >> >>> Okay for gcc trunk and backports to gcc-4_5-branch/gcc-4_6-branch? >> >> Ok. > > Mike, > Thanks for the commit. This leaves us with the boehm-gc testsuite failures... > > FAIL: boehm-gc.c/gctest.c -O2 execution test > FAIL: boehm-gc.c/leak_test.c -O2 execution test > FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test > FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test > > at -m32/-m64 on x86_64-apple-darwin11 due to the -pie linker default. Iain had wanted > to leave these in place to encourage boehm-gc to be fixed but I doubt that is a realistic > goal in the near/middle term. Perhaps we could patch boehm-gc/testsuite/lib/boehm-gc.exp > to pass -fno-pie on darwin (now that it is functional)? I think we should just find a way to add -fno-pie... Are there any flags that are added because we are doing gc that we can key off of?
Patch
Index: gcc/testsuite/gcc.dg/darwin-segaddr.c =================================================================== --- gcc/testsuite/gcc.dg/darwin-segaddr.c (revision 181953) +++ gcc/testsuite/gcc.dg/darwin-segaddr.c (working copy) @@ -1,7 +1,7 @@ /* Check that -segaddr gets through and works. */ /* { dg-do run { target *-*-darwin* } } */ -/* { dg-options "-O0 -segaddr __TEST 0x200000" { target { *-*-darwin* && { ! lp64 } } } } */ -/* { dg-options "-O0 -segaddr __TEST 0x110000000" { target { *-*-darwin* && lp64 } } } */ +/* { dg-options "-O0 -segaddr __TEST 0x200000 -fno-pie" { target { *-*-darwin* && { ! lp64 } } } } */ +/* { dg-options "-O0 -segaddr __TEST 0x110000000 -fno-pie" { target { *-*-darwin* && lp64 } } } */ extern void abort (); Index: gcc/config/darwin10.h =================================================================== --- gcc/config/darwin10.h (revision 181953) +++ gcc/config/darwin10.h (working copy) @@ -26,7 +26,9 @@ along with GCC; see the file COPYING3. #define LINK_GCC_C_SEQUENCE_SPEC \ "%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ %{!static:%{!static-libgcc: \ - %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } %G %L" + %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ + %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ + %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L" #undef DEF_MIN_OSX_VERSION #define DEF_MIN_OSX_VERSION "10.6"
FSF gcc currently doesn't handle -fno-pie and friends properly under Lion. The darwin11 linker now defaults to -pie and must be explicitly passed -no_pie in such cases. The following patch extends LINK_GCC_C_SEQUENCE_SPEC to handle those instances which should pass -no_pie to the linker. The gcc.dg/darwin-segaddr.c testcase is also fixed by explicitly passing -fno-pie on dg-options since the test is meaningless for PIE. These patches also eliminate the excessive error failure currently since in gcc.dg/20020312-2.c as -fno-pic will now pass -no_pie to the linker which eliminates the linker warning... ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _f from /var/tmp//ccVNy9V9.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie Bootstrap and regression tested on x86_64-apple-darwin11. http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00287.html Okay for gcc trunk and backports to gcc-4_5-branch/gcc-4_6-branch? Jack Note that when -mmacosx-version-min=10.6 is used under Lion, the linker doesn't default to -pie so only the case of targeting 10.7 or later has to be considered. gcc/ 2011-12-03 Jack Howarth <howarth@bromo.med.uc.edu> * gcc/config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Pass -no_pie for non-PIC code when targeting 10.7 or later. gcc/testsuite/ 2011-12-03 Jack Howarth <howarth@bromo.med.uc.edu> * gcc.dg/darwin-segaddr.c: Use -no-pie.