Opened 17 months ago

Last modified 17 months ago

#63232 new defect

gcc7 @7.5.0_2: ld: unknown option: -no_pie

Reported by: kencu (Ken) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: leopard Cc:
Port: gcc7


After the application of i386 fixes when bootstrapping gcc using clang, that worked so nicely on 10.6, I am disappointed to see this on 10.5 Tiger Intel:

:info:build /usr/bin/g++-4.2 -arch i386 -std=gnu++98   -g -DIN_GCC    -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -fPIC -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-no_pie -o build/genenums \
:info:build 	    build/genenums.o build/read-md.o build/errors.o ../build-i386-apple-darwin9/libiberty/libiberty.a
:info:build ld: unknown option: -no_pie

Obviously, we have a bit more work to do. Exactly why this is happening on 10.5 but not on 10.6 with what appears to be the same linker version remains to be discovered.

Attachments (1)

gcc7-fail-leopard-i386.log (553.2 KB) - added by kencu (Ken) 17 months ago.

Download all attachments as: .zip

Change History (6)

Changed 17 months ago by kencu (Ken)

Attachment: gcc7-fail-leopard-i386.log added

comment:1 Changed 17 months ago by kencu (Ken)

bootstrapping gcc7 on 10.5 Intel forcing clang-N as the build compiler (I used macports-clang-7.0) seems to go down a workable path, and the build is proceeding on.

So -- it would seem that passing the no_pie linker option part of this fix is probably not needed, at least on <= 10.6, and seems to generate an error on 10.5 (and no doubt 10.4).

-no_pie     Do not make a position independent executable (PIE).  This is the default, when targeting 10.6 and earlier.

I'll work on this.

comment:2 Changed 17 months ago by kencu (Ken)

It seems that passing -Wl,-no_pie to /usr/bin/g++-4.2 results in the ld: unknown option: -no_pie error, but passing it to basically all the other compilers is tolerated and does not generate an error.

Not sure why. Perhaps the flag is screened out of the linker invocation?

comment:3 Changed 17 months ago by kencu (Ken)

I see what is going on.


is using


as the default linker, and that default linker does not support -no_pie.

For the immediate moment, until iain updates the patch to take this into account, I think I can only enable the no-pie fix if the bootstrap compiler matches *clang*.

comment:4 Changed 17 months ago by kencu (Ken)

disabling the patch is a bit problematic, it turns out, because the patches are overlapping and you can't get the asm patch without the no-pie patch unless I redo the patches somehow to make them not overlap.

This might be a better idea anyway. supply the flag if it is needed, and not if not needed:

+STAGE1_NO_PIE_FLAG := `case ${host} in *-*-darwin[1-9][1-9]*) echo -Wl,-no_pie ;; esac;`
+BOOT_NO_PIE_FLAG   := `case ${host} in *-*-darwin[1-9][1-9]*) echo -Wl,-no_pie ;; esac;`

comment:5 Changed 17 months ago by kencu (Ken)

In a57bebe0bddfcc1b616a3d760adc9d46bbc53db5/macports-ports (master):

gcc[6-7]: restrict i386 fixed to 10.6+ for now

the no-pie fix is not presently working correctly
on Leopard i386. Until this is properly fixed, restore
the previous behaviour on systems < 10.6.

see: #63232

Note: See TracTickets for help on using tickets.