[PATCH] D54125: [LTO] Drop non-prevailing definitions only if linkage is not local or appending
Teresa Johnson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 30 07:30:58 PST 2018
tejohnson added a comment.
In D54125#1313868 <https://reviews.llvm.org/D54125#1313868>, @void wrote:
> To replicate the failure, do this:
>
> $ llvm-ar rcsTD test-archive.o softirq.o irqdesc.o
> $ ld.gold -plugin LLVMgold.so -plugin-opt=thinlto -plugin-opt=-code-model=kernel -plugin-opt=jobs=6 -plugin-opt=-stack-alignment=8 -m elf_x86_64 -r -o test-object.o --whole-archive test-archive.o
> $ nm test-object.o | grep W
> 0000000000001370 W arch_dynirq_lower_bound
> 00000000000001b0 W arch_early_irq_init
> 00000000000001a0 W arch_probe_nr_irqs
> 0000000000000190 W early_irq_init
>
>
> Note that `early_irq_init` is still weak. It should have resolved to a concrete function.
I tried the reproducer and via -plugin-opts=save-temps I can see that the linker is telling LTO that the copy of early_irq_init in irqdesc.o is non-prevailing and that the softirq.o copy is prevailing. Therefore, with this patch the copy in irqdesc.o which is non-weak is dropped, and the weak copy in softirq.o is kept. So LTO seems to be doing what it should be based on what gold tells it.
The question is why is gold picking the weak symbol as the prevailing copy and not the strong one? Note that if the order of the object files is reversed in the llvm-ar invocation, the irqdesc.o copy of that symbol is the prevailing one as per the linker, and we keep the strong symbol instead.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54125/new/
https://reviews.llvm.org/D54125
More information about the llvm-commits
mailing list