[llvm-dev] lld + ThinLTO + fprofile-generate causes duplicate symbol errors

Pirama Arumuga Nainar via llvm-dev llvm-dev at lists.llvm.org
Tue May 8 19:50:10 PDT 2018


The duplicate symbol errors are for __llvm_profile_filename and
__llvm_profile_raw_version.
IIUC, these are supposed to be weak symbols but Thin LTO seems to break
this in some way.  This does't happen with gold or no LTO or full LTO.

$ cat > a.c
extern int foo();

int main() {
  return foo();
}

$ cat > b.c
int foo() {
  return 0;
}

$ clang a.c -fprofile-generate -flto=thin -c
$ clang b.c -fprofile-generate -flto=thin -c
$ clang a.o b.o -fprofile-generate -flto=thin -fuse-ld=lld
ld.lld: error: duplicate symbol: __llvm_profile_filename
>>> defined at a.c
>>>            lto.tmp:(__llvm_profile_filename)
>>> defined at b.c
>>>            lto.tmp:(.rodata.__llvm_profile_filename+0x0)

ld.lld: error: duplicate symbol: __llvm_profile_raw_version
>>> defined at a.c
>>>            lto.tmp:(__llvm_profile_raw_version)
>>> defined at b.c
>>>            lto.tmp:(.rodata.__llvm_profile_raw_version+0x0)
clang-7: error: linker command failed with exit code 1 (use -v to see
invocation)
Makefile:10: recipe for target 'a.out' failed
make: *** [a.out] Error 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180509/dc0453a1/attachment.html>


More information about the llvm-dev mailing list