Hi, the implementation of IL linking in GCC is currently blocked by this. When compiling with gcc -r the linker plugin claims the LTO files and uses GCC to merge them into one LTO file which is then streamed. It would be great to fix ld and gold to not complain about this. Honza
A testcase?
Apply patch https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03530.html and try to incremental link LTO files.
Created attachment 8838 [details] A patch Try this.
A simple testcase with GCC 5: [hjl@gnu-6 bin]$ cat /tmp/x.c #include <stdio.h> int main () { printf ("hello\n"); return 0; } [hjl@gnu-6 bin]$ gcc -flto -c /tmp/x.c [hjl@gnu-6 bin]$ ld.bfd -r x.o -o reloc.o ld.bfd: x.o: plugin needed to handle lto object [hjl@gnu-6 bin]$ ld.gold -r x.o -o reloc.o x.o: plugin needed to handle lto object [hjl@gnu-6 bin]$
Created attachment 8839 [details] A patch for ld and gold
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bebf4942b083027860539b7c5e0649714b92e401 commit bebf4942b083027860539b7c5e0649714b92e401 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Dec 10 11:28:48 2015 -0800 ld -r doesn't need plugin for slim lto object Plugin isn't required on slim lto object for relocatable link. PR ld/19317 * symtab.cc (Symbol_table::add_from_relobj): Don't complain plugin needed to handle slim lto object for relocatable link.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c5847ba7267b6eedd4b750f5eeece3ec037a27fd commit c5847ba7267b6eedd4b750f5eeece3ec037a27fd Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Dec 10 12:35:35 2015 -0800 ld -r doesn't need plugin for slim lto object Plugin isn't required on slim lto object for relocatable link. bfd/ PR ld/19317 * linker.c (_bfd_generic_link_add_one_symbol): Don't complain plugin needed to handle slim lto object for relocatable link. ld/testsuite/ PR ld/19317 * ld-plugin/lto.exp (lto_no_fat): New. (lto_link_tests): Add a test for PR ld/19317. (lto_run_tests): Likewise. (run_ld_link_tests): Likewise.
Fixed for 2.27.
The master branch has been updated by YunQiang Su <syq@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a0631c1501c113c04891c9a24a9ff5276257f28d commit a0631c1501c113c04891c9a24a9ff5276257f28d Author: YunQiang Su <yunqiang.su@cipunited.com> Date: Tue May 16 09:46:46 2023 +0800 MIPS: fix some ld testcases with compiler 1. config/default.exp: use -mabi=32 not for -gnuabi64 xfail_from_runlist: remove an element and mark it xfail. 2. ld-elf/indirect.exp: xfail indirect5a indirect5b indirect6a indirect6b indirect5c indirect5d indirect6c indirect6d 3. ld-elf/pr23658-2: mips output is not common 4. ld-elf/shared.exp: non-run on mips: Build libpr16496b.so 5. ld-elfvers/vers.exp: xfail vers4, vers4b no-run on mips: vers24a, vers24b, vers24c 6. ld-gc/gc.exp: add -KPIC into asflags for pr13683, pr14265, pr19161 7. ld-mips-elf/mips-elf.exp: use noarch for mips16-local-stubs-1, since it use -mips4 8. ld-plugin/lto.exp: no-run on mips/linux: PR ld/12982 add -KPIC into asflags for lto-3r, lto-5r, PR ld/19317 (2) xfail PR ld/15323 (4), PR ld/19317 (3) 9. ld-plugin/plugin.exp: xfail plugin claimfile lost symbol plugin claimfile replace symbol plugin claimfile replace symbol plugin claimfile lost symbol with source plugin claimfile replace symbol with source plugin claimfile resolve symbol with source plugin 2 with source lib load plugin 2 with source plugin 3 with source lib load plugin 3 with source 11. ld-selective/selective.exp: add -fno-PIC, which is needed for -mno-abicalls 12. ld-shared/shared.exp: xfail shared (non PIC), shared (PIC main, non PIC so)