llvm-project
llvm-project copied to clipboard
[Clang-CL] __attribute__(( weak )) vs LTO
a.cpp attribute(( weak )) void foo() {}
b.cpp void foo() {}
When a and b are linked w/ LTO you get duplicate symbol: void foo(). If LTO is not used then linking succeeds.
Thin vs full LTO does not make a difference.
FYI this seems specific to the COFF lld handling. It works fine as expected for ELF with clang++. I also confirmed that the bitcode generated by clang-cl -flto does give foo from a.cpp weak linkage: define weak dso_local void @"?foo@@YAXXZ"() #0 { ...