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

Teresa Johnson via llvm-dev llvm-dev at lists.llvm.org
Wed May 9 06:44:00 PDT 2018


Hi Pirama,

I can't reproduce with either lld or gold, using a compiler built from
head. What version is your clang?

Thanks,
Teresa

On Tue, May 8, 2018 at 7:50 PM Pirama Arumuga Nainar via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> 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
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>


-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180509/33007946/attachment.html>


More information about the llvm-dev mailing list