From 488cdbc6eff5fa764de4d46b791dd19df860b3e9 Mon Sep 17 00:00:00 2001 From: Matt Whitlock Date: Wed, 12 Aug 2026 01:07:40 -0400 Subject: [PATCH] configure: actually invoke the linker when testing --gc-sections Passing -Wl,--gc-sections to the compiler driver does exactly nothing unless the driver is instructed to invoke the linker. When it is not, Clang helpfully raises a warning, which -Werror turns into an error: error: -Wl,--gc-sections: 'linker' input unused [-Werror,-Wunused-command-line-argument] Remove the '-c' flag from the command line in have_function_sections() so that the linker will actually be invoked and thus the linker's support for --gc-sections will actually be tested. Changelog-None --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index f2352fa9fa567cfd91d9a99c2ce86969d8817ef4..6a29b36f49860d7f6541bbc45dbf438b53065dae 100755 --- a/configure +++ b/configure @@ -227,9 +227,9 @@ have_function_sections() TMPCFILE=$CONFIG_VAR_FILE.$$.c TMPOBJFILE=$CONFIG_VAR_FILE.$$.o - echo "int foo(void); int foo(void) { return 0; }" > $TMPCFILE + echo "int main(void); int main(void) { return 0; }" > $TMPCFILE # We *want* this to fail if we get a warning, hence use -Werror. - $1 $2 -Werror -ffunction-sections -Wl,--gc-sections -c $TMPCFILE -o $TMPOBJFILE + $1 $2 -Werror -ffunction-sections -Wl,--gc-sections $TMPCFILE -o $TMPOBJFILE } usage()