bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/26262] ld/plugin.c:plugin_notice may incorrectly replace an LTO


From: i at maskray dot me
Subject: [Bug ld/26262] ld/plugin.c:plugin_notice may incorrectly replace an LTO bfd_link_hash_defined with bfd_link_hash_undefweak
Date: Mon, 20 Jul 2020 02:21:51 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=26262

--- Comment #2 from Fangrui Song <i at maskray dot me> ---
(In reply to H.J. Lu from comment #1)
> clang has different behavior depending on -fuse-ld=XXX:
> 
> ...
> 
> It looks like a clang bug.

Thanks for the report. It is an LLVMgold.so bug. LLVMgold.so is used by GNU ld
and gold for clang LTO (full LTO or ThinLTO). The problem is that

clang -fuse-ld=bfd -flto a.o -o a -Wl,-plugin-opt=save-temps  # override a.o

I will fix it in https://reviews.llvm.org/D84132 and cherry pick it into
llvm-project's release/11.x branch (newly created for the 11.0.0 release).

Let's move back to the original topic. Use a different output filename (than
the basename of the source file) to avoid the -plugin-opt=save-temps issue.

-----

% clang -fuse-ld=bfd -fprofile-generate=out -flto a.c
-Wl,-y,__llvm_profile_raw_version -Wl,-plugin-opt=save-temps -o aa
/usr/bin/ld.bfd: /tmp/a-1cd442.o (symbol from plugin): definition of
__llvm_profile_raw_version
/usr/bin/ld.bfd:
/tmp/RelA/lib/clang/12.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
% ./aa
% llvm-profdata merge out -o a.profdata
% llvm-profdata show a.profdata  
Instrumentation level: Front-end    ### incorrect, it should be IR
Total functions: 1
Maximum function count: 1
Maximum internal block count: 0

% rm -r out
% clang -fuse-ld=gold -fprofile-generate=out -flto a.c
-Wl,-y,__llvm_profile_raw_version -Wl,-plugin-opt=save-temps -o aa
/tmp/a-3b2969.o: definition of __llvm_profile_raw_version
/tmp/RelA/lib/clang/12.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
aa.o: definition of __llvm_profile_raw_version
% ./aa
% llvm-profdata merge out -o a.profdata
% llvm-profdata show a.profdata  
Instrumentation level: IR
Total functions: 1
Maximum function count: 1
Maximum internal block count: 0

----

As my first comment says, you can inspect aa.resolution.txt to see that GNU ld
incorrectly thinks that __llvm_profile_raw_versio is non-prevailing.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]