Created attachment 472502 [details] Failed build.log When emerging app-emulation/dosemu-1.4.1_pre20130107-r3 with sys-devel/gcc[pie] and the gold linker enabled, the compilation fails with an error of the type /usr/lib/gcc/i686-pc-linux-gnu/7.1.0/../../../../i686-pc-linux-gnu/bin/ld: fatal error: binary output format not compatible with -shared or -pie or -r The error does not occur if _one_ of the following is added to CFLAGS/LDFLAGS a) -no-pie b) -fuse-ld=bfd Of course, (a) is like using sys-devel/gcc[-pie] and (b) is like not enabling the gold linker. Certainly neither is a good solution but just a workaround.
Created attachment 472504 [details] emerge --info of x86 system The attached emerge --info is from an x86 system, but the same issue occurs with an amd64 system (which has a very similar emerge --info, e.g. with identical package versions)
I forgot a possibly important information: the used compiler is sys-devel/gcc-7.1.0-r1
Interesting! isemu.S is a 16-bit stub code: .text .code16 .globl<>_start16 _start16: .... Even though result resides in ELF file of the host OS. Later compiled 16-bit code is copied as a .com file: $ x86_64-pc-linux-gnu-gcc -Wl,-warn-common -pie -fuse-ld=gold -Wl,-Ttext,100,-e,_start16,--oformat,binary -nostdlib -s -o ../../1.4.0.8/commands/isemu.com isemu.o I would argue in this particular case there is no much value in gcc being called instead of 'ld' directly. As for -fuse-ld=bdf / -fuse-ld=gold I'm not sure if it's -fuse-ld=bdf's infelicty to accept "-pie --oformat,binary" or ld.gold's omission. I'll file a bug to binutils and add a -no-pie workaround to ebuild.
Filed ld.gold bug upstream as https://sourceware.org/bugzilla/show_bug.cgi?id=21518
toolchain@, what would be the best test if current ${CC} supports -no-pie? In ghc i', using a version check i'm not happy about: 'tc-is-gcc && version_is_at_least 6.3 $(gcc-version)' What would be the preferred way to do it?
Pushed -no-pie workaround as: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60c042fa6d30842870a81da6090fc39960304a27 Thanks for the report!