https://sourceware.org/bugzilla/show_bug.cgi?id=23935
Bug ID: 23935 Summary: ld.bfd does not rescan fat LTO archives to resolve plugin-added references Product: binutils Version: 2.32 (HEAD) Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: vlad at ispras dot ru Target Milestone: --- #!/bin/sh - cat > prog.c << EOF #include <stdio.h> int main() { printf("hi\n"); return 0; } EOF cat > libfoo.c << EOF #include <stdio.h> int puts(const char *s) { return 0; } EOF gcc -c -flto -fno-builtin -ffat-lto-objects libfoo.c -o libfoo.o ar rcs libfoo.a libfoo.o # gold="-fuse-ld=gold" gcc -c -flto prog.c -o prog.o gcc $gold -Wl,-emain -L. -static -nostdlib prog.o -lfoo ################################################################################ >From <https://sourceware.org/ml/binutils/2014-08/msg00025.html> I gather that in the presence of LTO recompiled objects, the archives are supposed to be rescanned automatically. This does not happen in the example above. When LTOing prog.o, GCC transforms the printf call to a puts call. I expect this new call to see a resolution in libfoo.a. And it happens indeed, if one uses Gold. Not so for the BFD linker: /usr/bin/ld: /tmp/ccvITLI4.ltrans0.ltrans.o: in function `main': <artificial>:(.text+0xc): undefined reference to `puts' Notice the -ffat-lto-objects switch. Without it, libfoo.a would contain only LTO bytecode and both linkers would error out. It seems, the logic is off somewhere taking "contains LTO bytecode" for "contains only LTO bytecode". -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils