checked with the 2.23 branch (and gcc-4.7), original report at http://gcc.gnu.org/PR55592 $ cat foo.c int main() { } $ gcc foo.c && ldd a.out |grep libgcc_s $ gcc -flto foo.c && ldd a.out |grep libgcc_s libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fb214381000) works with gold: $ gcc -B /usr/lib/gold-ld -flto foo.c && ldd a.out |grep libgcc_s $ libgcc is linked as: -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
I have this patch in the Linux binutils: diff --git a/ld/plugin.c b/ld/plugin.c index da99e77..2966f0f 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -217,6 +220,17 @@ plugin_opt_plugin_arg (const char *arg) if (!last_plugin) return set_plugin_error (_("<no plugin>")); + /* Ignore -pass-through= from GCC driver. */ + if (*arg == '-') + { + const char *p; + for (p = arg + 1; p; p++) + if (*p != '-') + break; + if (strncmp (p, "pass-through=", 13) == 0) + return 0; + } + newarg = xmalloc (sizeof *newarg); newarg->arg = arg; newarg->next = NULL; However, I don't know how safe it is in the FSF binutils.
HJ, please install this patch. I think the -pass-through hack is entirely redundant nowadays.
Tidier patch at https://sourceware.org/ml/binutils/2014-08/msg00025.html
Patch applied. git commit 97964ab3
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9910b1c8f3b0821944303fbcb4ef4c8872cf4e08 commit 9910b1c8f3b0821944303fbcb4ef4c8872cf4e08 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 3 08:24:50 2015 -0800 Add a testcase for PR ld/14918 PR ld/14918 * ld-plugin/lto.exp (lto_link_elf_tests): Add PR ld/14918 test. * ld-plugin/pr14918.c: New file. * ld-plugin/pr14918.d: Likewise.
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=231ca753239211b72eb761593083a0ee859274e7 commit 231ca753239211b72eb761593083a0ee859274e7 Author: Nick Clifton <nickc@redhat.com> Date: Thu Sep 28 11:33:20 2017 +0100 Skip the PR 14918 linker test for ARM targets. I am applying a patch that has been lying around in the Fedora binutils sources for a while. It skips the PR14918 linker test for ARM based targets. This test checks that libgcc is not included in a link of an empty executable. This works for most targets, but on the ARM the crt1.o startup code calls __libc_csu_init which is in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, and so the test fails.