https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111238
Bug ID: 111238 Summary: libstdc++ tests should use -Wl,-gc-sections in more configurations Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: clyon at gcc dot gnu.org CC: jwakely.gcc at gmail dot com Target Milestone: --- As a follow-up to bug #104167, I've looked in more detail after Jonathan's last comment there: > Does arm-eabi build libstdc++.a with -ffunction-sections? > The tests should be built with -Wl,--gc-sections which combined with > -ffunction-sections should mean that the tests do not pull in symbols > they don't need. So on arm-eabi, libstdc++'s configure correctly detects that -ffunction-sections is supported, and builds with it. However, when running the testsuite, it lacks -Wl,-gc-sections. I checked manually that adding this flag makes the link succeed for the offending testcase I reported in PR #104167. This happens because we are not in a native mode build, so configure.ac does not run GLIBCXX_CHECK_LINKER_FEATURES, and even when running the "cross target environment" part of the configuration, we do not even make use of GLIBCXX_CROSSCONFIG because I configure with --with-newlib. That being said, GLIBCXX_CROSSCONFIG makes use of -Wl,--gc-sections only for *-tpf targets, so even configuring without --with-newlib wouldn't help. Maybe we could call GLIBCXX_CHECK_LINKER_FEATURES only when not in canadian-cross mode?