[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 Iain Sandoe iains at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Comment #33 from Iain Sandoe iains at gcc dot gnu.org 2011-06-25 11:18:56 UTC --- fixed, any darwin-11-specific issues would perhaps be better dealt with in a separate PR.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #32 from Iain Sandoe iains at gcc dot gnu.org 2011-06-25 11:17:39 UTC --- Author: iains Date: Sat Jun 25 11:17:35 2011 New Revision: 175397 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=175397 Log: PR driver/49371 * config/darwin.c (darwin_override_options): Improve warning when mdynamic-no-pic is given together with fPIC/fpic, also warn when it is given with fpie/fPIE. * config/darwin.h (PIE_SPEC): New, (LINK_SPEC): Use PIE_SPEC. * config/darwin9.h (PIE_SPEC): New. Modified: trunk/gcc/ChangeLog trunk/gcc/config/darwin.c trunk/gcc/config/darwin.h trunk/gcc/config/darwin9.h
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 Dominique d'Humieres dominiq at lps dot ens.fr changed: What|Removed |Added CC||ramana.radhakrishnan at arm ||dot com, robertcnelson at ||gmail dot com --- Comment #30 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-15 16:17:48 UTC --- It seems to affect also armv7l-unknown-linux-gnueabi (see http://gcc.gnu.org/ml/gcc-testresults/2011-06/msg01644.html ).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 m...@gcc.gnu.org mrs at gcc dot gnu.org changed: What|Removed |Added CC||mrs at gcc dot gnu.org --- Comment #31 from mrs at gcc dot gnu.org mrs at gcc dot gnu.org 2011-06-16 02:28:54 UTC --- I've checked in the config/mh-darwin change to always turn of -pie. This is orthogonal to all the other changes. This is necessary for example for a darwin hosted linux targeted cross compiler.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #28 from Jack Howarth howarth at nitro dot med.uc.edu 2011-06-15 03:15:44 UTC --- Created attachment 24532 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=24532 patch to fix pie handling for darwin11
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #29 from Jack Howarth howarth at nitro dot med.uc.edu 2011-06-15 03:21:04 UTC --- While we are fixing the pie/PIE handling on darwin, we should also address a change required for darwin11 which defaults its linker to -pie. This causes breakage in gcj and pch since FSF gcc isn't defaulting to -fpie yet. The simple fix is just pass -no_pie on LINK_GCC_C_SEQUENCE_SPEC for 10.7 or later whenever the compiler isn't trying to generate pie/PIE code. This change on top of Iain's patch eliminates the pch and gcj failures.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 Iain Sandoe iains at gcc dot gnu.org changed: What|Removed |Added Attachment #24501|0 |1 is obsolete|| --- Comment #23 from Iain Sandoe iains at gcc dot gnu.org 2011-06-13 12:57:54 UTC --- Created attachment 24509 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=24509 v3: corrects a typo and reduces the number of options identified in the compiler warning OK. So this corrects a typo (overides) and also removes '-pie' from the compiler warning (since this is a linker option, it should not be mentioned there). The linker warning does identify pie, fpie and fPIE - since, for compatibility with system tools, we make fpie/PIE imply -pie. The 'engineering' is mostly done; However, what is still needed is adjustment of test-cases, I don't have time to do that this week - but if Dominique would be willing - I'd be happy to test a combined patch on Darwin8/i686-Darwin9.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #24 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-13 13:12:36 UTC --- However, what is still needed is adjustment of test-cases ... Which test cases? on x86_64-apple-darwin10 the testsuite passes with only the known failures (for ppc I only tested the tls tests: the full test takes ~20 hours!-).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #25 from Iain Sandoe iains at gcc dot gnu.org 2011-06-13 13:27:22 UTC --- (In reply to comment #24) However, what is still needed is adjustment of test-cases ... Which test cases? on x86_64-apple-darwin10 the testsuite passes with only the known failures (for ppc I only tested the tls tests: the full test takes ~20 hours!-). I had assumed that the cases noted in comment #15 were test fails - if they were just examples, then we are probably 'there' modulo a re-test on darwin8.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #26 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-13 13:46:33 UTC --- (In reply to comment #25) I had assumed that the cases noted in comment #15 were test fails - if they were just examples, then we are probably 'there' modulo a re-test on darwin8. They were just extra tests motivated by some doubts you expressed in the thread (BTW on powerpc-apple-darwin9 I get the cc1/f951 warning for both -m32 and -m64).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #27 from Iain Sandoe iains at gcc dot gnu.org 2011-06-13 14:18:58 UTC --- (In reply to comment #26) (In reply to comment #25) I had assumed that the cases noted in comment #15 were test fails - if they were just examples, then we are probably 'there' modulo a re-test on darwin8. They were just extra tests motivated by some doubts you expressed in the thread OK, my misunderstanding ;-) (BTW on powerpc-apple-darwin9 I get the cc1/f951 warning for both -m32 and -m64). that's correct - mdynamic-no-pic is active for m64/powerpc (but not for m64/x86). so .. I'll retest on darwin8 .. and apply to trunk if all is OK there.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #10 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 09:56:28 UTC --- Created attachment 24496 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=24496 adjust specs for darwin to make 'pie', 'fpie' and 'fPIE' do the same. This is might be a step in the right direction - it 'works' on Darwin 8 9 and from Jack's comment on Darwin 11 (which makes one expect it to be OK on Darwin 10). However: 1. It does not prove that the code-gen is right/appropriate (I assume the test-cases do - but I don't have time to read code right now). 2. It is *incomplete* - there should be a check in darwin.c that determines if mdynamic-no-pic is given at the same time as pie (they are not compatible). The linker will reject-it - but we should deal with it earlier. 3. It assumes that mapping all of 'pie' 'fpie' fPIE' = pie is the Right Thing to do on Darwin. I don't know that this is necessarily the case (it might be more appropriate to reject unused ones with an error). However, at present, we're no worse off than the system compliers in that they accept the flags and ignore them silently.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #11 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-12 11:00:03 UTC --- (which makes one expect it to be OK on Darwin10). Confirmed on x86_64-apple-darwin10.7.0.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #12 from joseph at codesourcery dot com joseph at codesourcery dot com 2011-06-12 12:48:53 UTC --- The reason for the error is that no spec matches the option. For most targets, the option is matched in LINK_PIE_SPEC (only), which is part of LINK_COMMAND_SPEC; Darwin uses its own LINK_COMMAND_SPEC (as does DJGPP). I would advise making Darwin behave similarly to other targets by including an appropriate spec for this option in Darwin's LINK_COMMAND_SPEC.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #13 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 13:00:49 UTC --- (In reply to comment #12) The reason for the error is that no spec matches the option. For most targets, the option is matched in LINK_PIE_SPEC (only), which is part of LINK_COMMAND_SPEC; Darwin uses its own LINK_COMMAND_SPEC (as does DJGPP). I would advise making Darwin behave similarly to other targets by including an appropriate spec for this option in Darwin's LINK_COMMAND_SPEC. that's what the attached patch @comment #10 does. there are some potential refinements; (a) the warning message from cc1 is a bit non-helpful when mdynamic-no-pic is combined with pie - since it refers to fpic/fPIC which the user did not actually supply (although she did imply it)., (b) something like #undef PIE_SPEC #define PIE_SPEC \ %{fpie|pie|fPIE: \ %{mdynamic-no-pic: %n'-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE'; \ :-pie}} would avoid the linker error when the combination is given - since the pic is already overridden, at least it would be consistent.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 Iain Sandoe iains at gcc dot gnu.org changed: What|Removed |Added Attachment #24496|0 |1 is obsolete|| --- Comment #14 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 14:47:27 UTC --- Created attachment 24501 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=24501 refined version that mentions pie in compiler warnings, and removes the pie option for ld when mdynamic-no-pic is given this adds a couple of minor improvements: a. the compiler will now mention pie as well as pic when warning about incompatibility with -mdynamic-no-pic. b. the pie option will no longer be passed to collect2 if -mdynamic-no-pic is given. this produces: $ ./gcc/xgcc -Bgcc /GCC/tests/hello.c -o hc -fpie -mdynamic-no-pic cc1: warning: ‘-mdynamic-no-pic’ overrides ‘-fpic’, ‘-fPIC’, ‘-fpie’, ‘-fPIE’ or ‘-pie’ [enabled by default] xgcc: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' or $ ./gcc/gfortran -Bgcc -B powerpc-apple-darwin9/libgfortran -L powerpc-apple-darwin9/libgfortran/.libs/ ../tests/helloi.F90 -o hi -mdynamic-no-pic -fpie f951: warning: ‘-mdynamic-no-pic’ overrides ‘-fpic’, ‘-fPIC’, ‘-fpie’, ‘-fPIE’ or ‘-pie’ [enabled by default] gfortran: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' IMO this is better than a line1:0 warning and at least mentions the pie option. As far as the second info - this is related to the ld phase (I suppose we could mention ld specifically, but it seemed to start getting unwieldy). We need the second 'info', since it protects against pie + mdynamic-no-pic on link-only lines.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #15 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-12 18:40:01 UTC --- I have bootstrapped gcc on x86_64-apple-darwin10.7.0 with the patch in comment #14 and the tests for gcc and tls.exp pass without unexpected failure. I just noticed the following oddity: [macbook] f90/bug% gfc -m64 -fpie -mdynamic-no-pic pr49331.f90 gfc: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' [macbook] f90/bug% gfc -m32 -fpie -mdynamic-no-pic pr49331.f90 f951: warning: '-mdynamic-no-pic' overrides '-fpic', '-fPIC', '-fpie', '-fPIE' or '-pie' [enabled by default] gfc: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' [macbook] f90/bug% gcc47 -m64 -fpie -mdynamic-no-pic backtrace.c gcc47: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' [macbook] f90/bug% gcc47 -m32 -fpie -mdynamic-no-pic backtrace.c cc1: warning: '-mdynamic-no-pic' overrides '-fpic', '-fPIC', '-fpie', '-fPIE' or '-pie' [enabled by default] gcc47: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' Is it expected that the warning appears with -m32, but not with -m64? I also got [macbook] f90/bug% gcc47 -m32 -fno-PIC -pie backtrace.c ld: cannot link -pie: -mdynamic-no-pic codegen found in _myfunc3 from /var/tmp//cccDWsse.o collect2: error: ld returned 1 exit status
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #16 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 19:01:51 UTC --- (In reply to comment #15) I have bootstrapped gcc on x86_64-apple-darwin10.7.0 with the patch in comment #14 and the tests for gcc and tls.exp pass without unexpected failure. I just noticed the following oddity: [macbook] f90/bug% gfc -m64 -fpie -mdynamic-no-pic pr49331.f90 gfc: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' [macbook] f90/bug% gfc -m32 -fpie -mdynamic-no-pic pr49331.f90 f951: warning: '-mdynamic-no-pic' overrides '-fpic', '-fPIC', '-fpie', '-fPIE' or '-pie' [enabled by default] gfc: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' [macbook] f90/bug% gcc47 -m64 -fpie -mdynamic-no-pic backtrace.c gcc47: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' [macbook] f90/bug% gcc47 -m32 -fpie -mdynamic-no-pic backtrace.c cc1: warning: '-mdynamic-no-pic' overrides '-fpic', '-fPIC', '-fpie', '-fPIE' or '-pie' [enabled by default] gcc47: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' Those are correct - the options conflict [i.e. you can't have -pie and -mdynamic-no-pic at the same time]. Is it expected that the warning appears with -m32, but not with -m64? I also got Yes, I guess so on x86, mdynamic-no-pic has no effect for m64 (x86) ... ... I need to check what happens for m64 powerpc (but suspect it still applies). [macbook] f90/bug% gcc47 -m32 -fno-PIC -pie backtrace.c ld: cannot link -pie: -mdynamic-no-pic codegen found in _myfunc3 from /var/tmp//cccDWsse.o collect2: error: ld returned 1 exit status Hmm. That is an uncaught conflict, I think .. IIRC, pie requires position independent code.. so something's not 100% right... (perhaps there should be an error from cc1 in that case). thanks, as always for the checking - - don't know when/if I'll get a chance to look further at this .. so anyone else is welcome to take my patchlet forward ...
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #17 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 19:06:15 UTC --- (In reply to comment #16) (In reply to comment #15) [macbook] f90/bug% gcc47 -m32 -fno-PIC -pie backtrace.c what happens for gcc47 -m32 -fno-PIC -fpie backtrace.c ?
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #18 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 19:16:05 UTC --- (In reply to comment #16) [macbook] f90/bug% gcc47 -m32 -fno-PIC -pie backtrace.c ld: cannot link -pie: -mdynamic-no-pic codegen found in _myfunc3 from /var/tmp//cccDWsse.o collect2: error: ld returned 1 exit status OK, now I look harder, that is correct. The User has instructed the compiler NOT to generate position independent code - (so it will generate mdynamic-no-pic, by default) - [at m32, m64 should make no difference on x86] The User has then told the linker to link '-pie' which it creates a conflict. ... so, I think this is the correct outcome (if not immediately palatable).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #19 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-12 19:54:40 UTC --- what happens for gcc47 -m32 -fno-PIC -fpie backtrace.c ? [macbook] f90/bug% gcc47 -m32 -fno-PIC -fpie backtrace.c [macbook] f90/bug% otool -hv a.out a.out: Mach header magic cputype cpusubtype capsfiletype ncmds sizeofcmds flags MH_MAGICI386ALL 0x00 EXECUTE12 1236 NOUNDEFS DYLDLINK TWOLEVEL PIE
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #20 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 20:10:10 UTC --- (In reply to comment #19) what happens for gcc47 -m32 -fno-PIC -fpie backtrace.c ? [macbook] f90/bug% gcc47 -m32 -fno-PIC -fpie backtrace.c [macbook] f90/bug% otool -hv a.out a.out: Mach header magic cputype cpusubtype capsfiletype ncmds sizeofcmds flags MH_MAGICI386ALL 0x00 EXECUTE12 1236 NOUNDEFS DYLDLINK TWOLEVEL PIE that's correct - the pie will override the no-PIC because it comes later on the c/l. --- However, sorry, that was a 'red herring' - the outcome is as expected for the original set of options - as per comment #18. we have some slight differences from the system tools - which treat the options more restrictively than GCC; but I don't think those differences will matter to anyone unless they issue conflicting flags - which will error on GCC but sometimes be silently ignored by the system tools.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #21 from Iain Sandoe iains at gcc dot gnu.org 2011-06-12 20:33:24 UTC --- check m64 on powerpc-darwin9 and it appears to do the Right Thing; mdynamic-no-pic still applies for m64/powerpc and we get: $ ./gcc/xgcc -Bgcc ../tests/hello.c -o hc -fpie -mdynamic-no-pic -m64 cc1: warning: ‘-mdynamic-no-pic’ overrides ‘-fpic’, ‘-fPIC’, ‘-fpie’, ‘-fPIE’ or ‘-pie’ [enabled by default] xgcc: note: '-mdynamic-no-pic' overides '-pie', '-fpie' or '-fPIE' c.f. system compiler: $ gcc-4.2 ../tests/hello.c -o hc -fpie -mdynamic-no-pic -m64 ../tests/hello.c:1: warning: -mdynamic-no-pic overrides -fpic or -fPIC ld: absolute addressing (perhaps -mdynamic-no-pic) used in _main from /var/folders/17/17RRKLjrExOvsenOKYzNhk++-0E/-Tmp-//cc5VGi6o.o not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs (I think the messages issued by the patched compiler are clearer than the system tools .. but opinions welcome).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #22 from Mike Stump mikestump at comcast dot net 2011-06-13 03:32:11 UTC --- Ok. (When the engineering work is done.)
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #1 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-11 12:07:39 UTC --- It seems that there are the same failures on i686-pc-linux-gnu (see http://gcc.gnu.org/ml/gcc-testresults/2011-06/msg01202.htm ).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #2 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-11 12:17:24 UTC --- It seems that there are the same failures on i686-pc-linux-gnu In this case it is runtime failures of the kind: ./run-le.exe: error while loading shared libraries: cannot restore segment prot after reloc: Permission denied FAIL: gcc.dg/torture/tls/run-le.c -O0 -pie -fpie execution test (see http://glutton.geoffk.org/HEAD/native-logsum/gcc/testsuite/gcc/gcc.log.gzip ).
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 Iain Sandoe iains at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2011.06.11 12:48:38 Ever Confirmed|0 |1 --- Comment #3 from Iain Sandoe iains at gcc dot gnu.org 2011-06-11 12:48:38 UTC --- (In reply to comment #0) in gcc/testsuite/lib/target-supports.exp, but I think the darwin driver should be fixed. agreed, (-pie is silently ignored by Apple's gcc and gcc-4.2). we just need an 'ignore' line in the appropriate .opt I guess.. FWIW: -fpie is working correctly: $ ./gcc/xgcc -Bgcc ../tests/hello.c -o hc -fpie $ otool -hv hc hc: Mach header magic cputype cpusubtype capsfiletype ncmds sizeofcmds flags MH_MAGIC PPCppc7400 0x00 EXECUTE12 1168 NOUNDEFS DYLDLINK TWOLEVEL PIE
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #4 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-11 16:22:20 UTC --- What is the meaning of %{fpie:-pie} in gcc/config/darwin.h?
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #5 from Iain Sandoe iains at gcc dot gnu.org 2011-06-11 16:52:59 UTC --- (In reply to comment #4) What is the meaning of %{fpie:-pie} in gcc/config/darwin.h? that causes '-pie' to be placed on sub-command lines when '-fpie' is seen (and thus -pie is forwarded to sub-processes of the driver - including the linker). one could use 'fpie|pie' which would substitute -pie for either input - however, I am not sure if there are different intentions for '-pie', '-fpie' and '-fPIE'. I googled briefly, but without much light shed. In the case of the Apple/system compilers: -pie and -fPIE are ignored (silently). The only option that produces PIE executables is -fpie.
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 Jack Howarth howarth at nitro dot med.uc.edu changed: What|Removed |Added CC||howarth at nitro dot ||med.uc.edu --- Comment #6 from Jack Howarth howarth at nitro dot med.uc.edu 2011-06-11 17:04:21 UTC --- This came from http://gcc.gnu.org/viewcvs?view=revisionrevision=125270 and proposed patch was discussed in these messages... http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00070.html http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00072.html http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00073.html http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00083.html http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00296.html If -pie is darwin9 later, shouldn't its passage to the linker be in darwin9.h instead?
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #7 from Iain Sandoe iains at gcc dot gnu.org 2011-06-11 17:44:13 UTC --- (In reply to comment #6) If -pie is darwin9 later, shouldn't its passage to the linker be in darwin9.h instead? yes, this will need sorting out too - darwin 8' s ld will barf on '-pie'. so you could move the spec to darwin9.h -- - or maybe better put something like this (completely untested, not even checked to compile) Index: gcc/config/darwin.h === --- gcc/config/darwin.h(revision 174947) +++ gcc/config/darwin.h(working copy) @@ -226,6 +226,8 @@ extern GTY(()) int darwin_ms_struct; #define LINK_SYSROOT_SPEC %{isysroot*:-syslibroot %*} #endif +#define PIE_SPEC {-fpie|pie|fPIE:} + /* Please keep the random linker options in alphabetical order (modulo 'Z' and 'no' prefixes). Note that options taking arguments may appear multiple times on a command line with different arguments each time, @@ -290,7 +292,7 @@ extern GTY(()) int darwin_ms_struct; %:version-compare( 10.5 mmacosx-version-min= -multiply_defined) \ %:version-compare( 10.5 mmacosx-version-min= suppress)}} \ %{Zmultiplydefinedunused*:-multiply_defined_unused %*} \ - %{fpie:-pie} \ +PIE_SPEC \ %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \ %{read_only_relocs} \ %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} \ Index: gcc/config/darwin9.h === --- gcc/config/darwin9.h(revision 174947) +++ gcc/config/darwin9.h(working copy) @@ -35,6 +35,9 @@ along with GCC; see the file COPYING3. If not see /* Tell collect2 to run dsymutil for us as necessary. */ #define COLLECT_RUN_DSYMUTIL 1 +#undef PIE_SPEC +#define PIE_SPEC %{fpie|pie|fPIE:-pie} + #undef ASM_OUTPUT_ALIGNED_COMMON #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)\ do {\
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #8 from Jack Howarth howarth at nitro dot med.uc.edu 2011-06-11 19:56:41 UTC --- (In reply to comment #7) This patch bootstraps fine on x86_64-apple-darwin11 and passes -pie as expected... [MacPro:~] howarth% gcc-fsf-4.7 -fpie -v himenoBMTxpa.c ... /usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.7.0 -pie -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/sw/lib/gcc4.7/lib/gcc/x86_64-apple-darwin11.0.0/4.7.0 -L/sw/lib/gcc4.7/lib/gcc/x86_64-apple-darwin11.0.0/4.7.0/../../.. /var/folders/1l/n78sywl52lz6kkys6nv7mnphgp/T//ccwqghgh.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
[Bug driver/49371] xgcc: error: unrecognized option '-pie' on *-apple-darwin*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49371 --- Comment #9 from Iain Sandoe iains at gcc dot gnu.org 2011-06-11 20:08:35 UTC --- (In reply to comment #8) (In reply to comment #7) This patch bootstraps fine on x86_64-apple-darwin11 and passes -pie as expected... [MacPro:~] howarth% gcc-fsf-4.7 -fpie -v himenoBMTxpa.c ... /usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.7.0 -pie -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/sw/lib/gcc4.7/lib/gcc/x86_64-apple-darwin11.0.0/4.7.0 -L/sw/lib/gcc4.7/lib/gcc/x86_64-apple-darwin11.0.0/4.7.0/../../.. /var/folders/1l/n78sywl52lz6kkys6nv7mnphgp/T//ccwqghgh.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v it is, however, wrong for darwin8 - there's a typo: +#define PIE_SPEC {-fpie|pie|fPIE:} ---^ (should not have a '-'). thus: +#define PIE_SPEC {fpie|pie|fPIE:}