Building glibc fails with -ffunction-sections/-fdata-sctions in CFLAGS and --gc-sections in LDFLAGS: x86_64-pc-linux-gnu-gcc -m64 -pipe -march=znver2 -O2 -fcf-protection=none -Wl,-O1,--as-needed,--gc-sections,-z,now,-z,pack-relative-relocs -nostdlib -nostartfiles -r -o /tmp/portage/sys-libs/glibc-2.40-r3/work/build-amd64-x86_64-pc-linux-gnu-nptl/csu/crt1.o /tmp/portage/sys-libs/glibc-2.40-r3/work/build-amd64-x86_64-pc-linux-gnu-nptl/csu/start.o /tmp/portage/sys-libs/glibc-2.40-r3/work/build-amd64-x86_64-pc-linux-gnu-nptl/csu/abi-note.o /tmp/portage/sys-libs/glibc-2.40-r3/work/build-amd64-x86_64-pc-linux-gnu-nptl/csu/init.o /tmp/portage/sys-libs/glibc-2.40-r3/work/build-amd64-x86_64-pc-linux-gnu-nptl/csu/static-reloc.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: --gc-sections requires a defined symbol root specified by -e or -u Reproducible: Always Steps to Reproduce: 1. add -fdata-sections -ffunction-sections to CFLAGS, --gc-sections to LDFLAGS 2. try to build glibc 3. failure Reporting it here after consultation with sam on IRC. It seems that CFLAGS are filtered and -fdata-sections -ffunction-sections are removed, but LDFLAGS is unfiltered and therefore --gc-sections cannot work either.
Created attachment 904820 [details] Full build log
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fbe427b18343c5ad45bc2fd56ae691f1c95295ff commit fbe427b18343c5ad45bc2fd56ae691f1c95295ff Author: Sam James <sam@gentoo.org> AuthorDate: 2024-10-07 15:53:11 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-10-07 15:54:58 +0000 sys-libs/glibc: filter -Wl,--gc-sections This fails to link when building static-reloc.o but it's broken in other ways too -- amonakov points out that glibc's linker scripts aren't ready for gc-sections (odd runtime side-effects like I/O flushing at exit not occurring), see PR21557 comment 0 for it being mentioned as an aside. Thanks to holgerh for reporting. Closes: https://bugs.gentoo.org/940709 Signed-off-by: Sam James <sam@gentoo.org> sys-libs/glibc/glibc-2.19-r3.ebuild | 5 +++++ sys-libs/glibc/glibc-2.31-r7.ebuild | 5 +++++ sys-libs/glibc/glibc-2.32-r8.ebuild | 5 +++++ sys-libs/glibc/glibc-2.33-r14.ebuild | 5 +++++ sys-libs/glibc/glibc-2.34-r14.ebuild | 5 +++++ sys-libs/glibc/glibc-2.35-r11.ebuild | 5 +++++ sys-libs/glibc/glibc-2.36-r8.ebuild | 5 +++++ sys-libs/glibc/glibc-2.37-r10.ebuild | 5 +++++ sys-libs/glibc/glibc-2.38-r13.ebuild | 5 +++++ sys-libs/glibc/glibc-2.39-r10.ebuild | 5 +++++ sys-libs/glibc/glibc-2.39-r6.ebuild | 5 +++++ sys-libs/glibc/glibc-2.39-r9.ebuild | 5 +++++ sys-libs/glibc/glibc-2.40-r3.ebuild | 5 +++++ sys-libs/glibc/glibc-2.40-r4.ebuild | 5 +++++ sys-libs/glibc/glibc-9999.ebuild | 5 +++++ 15 files changed, 75 insertions(+)