Just upgraded to the sys-devel/gcc-11.2.0 and wanted to rebuild sys-libs/glibc-2.33-r1 with static-pie flag enabled, but hit the problem: configure: error: linker support for static PIE needed relevant snippet from the config.log file: configure:111: checking for linker static PIE support configure:125: x86_64-pc-linux-gnu-gcc -m64 -pipe -march=native -O2 -Wl,-O1 -Wl,--as-needed -fuse-ld=bfd -pipe -march=native -O2 -Wl,-O1 -Wl,--as-needed -fuse-ld=bfd -nostartfiles -nostdlib -fno-stack-protector -Wl,-pie -o conftest conftest.s 1>&5 /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: /var/tmp/portage/sys-libs/glibc-2.33-r1/temp/ccWK2rps.o: relocation R_X86_64_PC32 against undefined symbol `foo' can not be used when making a PIE object; recompile with -fPIE /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: final link failed: bad value collect2: error: ld returned 1 exit status configure:128: $? = 1 configure:136: result: no configure:139: error: linker support for static PIE needed Reproducible: Always
Created attachment 744531 [details] emerge --info
Created attachment 744534 [details] config.log Configure log file
This reproduces for me when using sys-devel/binutils-2.37_p1. Disappears with sys-devel/binutils-2.36.1-r2.
This happens with sys-devel/gcc-10.3.0-r2 as well. This patch fixes it: <https://sourceware.org/pipermail/libc-alpha/2021-July/128802.html>.
I have reproduced this bug too. As hinted by Tee and Thomas, it is not related to gcc but to binutils. sys-devel/gcc-11.2.0 and sys-devel/binutils-2.37_p1: Fails sys-devel/gcc-10.3.0 and sys-devel/binutils-2.37_p1: Fails sys-devel/gcc-11.2.0 and sys-devel/binutils-2.36.1: Works sys-devel/gcc-10.3.0 and sys-devel/binutils-2.37_p1: Works
Created attachment 746292 [details] Example weak symbol access
Created attachment 746295 [details] Resulting assembly file As we can see when using -static -pie -O2 gcc (both 10.3.0 and 11.2.0) produce the same assembly file which uses gotpcrel as hinted by https://sourceware.org/bugzilla/show_bug.cgi?id=21782#c6 https://sourceware.org/pipermail/libc-alpha/2021-July/128802.html has a patch removing those checks I think that it may be safer to keep the check but make it use gotpcrel as gcc does. I'll provide patches in a bit.
Digging deeper it seems that sys-libs/glibc-2.33-r6 has the backported upstream patch. Toolchain, can you request stabilization of that version (at least for AMD64 where this is an issue)?
This will be fixed once sys-libs/glibc-2.33-r7 is stabilized by #809410 If you want to solve this earlier, you can (at your own risk) install it now. To do so: * Make sure you read and understand the output of the news item: # eselect news read 2021-10-18-libxcrypt-migration-stable * Update your system to avoid dependency conflicts * add the following to your package.accept_keywords: =sys-libs/glibc-2.33-r7 ~amd64 =virtual/libcrypt-2 ~amd64 =sys-libs/libxcrypt-4.4.25 ~amd64 * if using a multilib profile add the following to your package.use: sys-libs/libxcrypt abi_x86_32 * finally emerge the new glibc and libxcrypt: # emerge -v1a =sys-libs/glibc-2.33-r7 =virtual/libcrypt-2 =sys-libs/libxcrypt-4.4.25
Thank you for doing the digging! glibc-2.33-r7 is now stable on amd64.