-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport coverage fixes #108
Backport coverage fixes #108
Conversation
D14468 added these dummy sections. This patch adds `__attribute__((used))` so that when compiled by GCC>=11 or (expected, D96838) Clang>=13 on some ELF platforms, these sections will get SHF_GNU_RETAIN to make sure they will not be discarded by ld --gc-sections. We are trying to get rid of LLD's "__start_/__stop_ references retain C identifier name sections" rule. If LLD drops the rule in the future (we will retain compatibility for `__llvm_prf_*` for a while), `__llvm_prf_*` will need to have the SHF_GNU_RETAIN flag, otherwise: ``` // __llvm_prf_cnts/__llvm_prf_data usually exist, but {names,vnds} may not exist. // Such diagnostics will happen with {cnts,data} as well if no input object file is instrumented. % clang++ -fprofile-generate a.cc -fuse-ld=lld -Wl,--gc-sections ld.lld: error: undefined hidden symbol: __start___llvm_prf_names >>> referenced by InstrProfilingPlatformLinux.c >>> InstrProfilingPlatformLinux.c.o:(__llvm_profile_begin_names) in archive /tmp/RelA/lib/clang/13.0.0/lib/linux/libclang_rt.profile-x86_64.a ... ``` Differential Revision: https://reviews.llvm.org/D96902
To make a kind of metadata section usage work, we want to drop the `__start_/__stop_ references retain C identifier name sections` rule from LLD (see D96914). If an application has no `__llvm_prf_data` input section surviving --gc-sections, LLD will error for undefined hidden `{__start_,__stop_}__llvm_prf_*` from `libclang_rt.profile-*`. Other `__llvm_prf_*` sections have similar issues. Making the references weak can address the problem. This probably enables the opportunity to drop zero size dummy sections in `InstrProfilingPlatformLinux.c`. Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D96936
They were added so that if no metadata section is present, `__start_llvm_prf_*` references would not cause "undefined symbol" errors. By switching to undefined weak symbols in D96936, the dummy sections are not needed. This patch is also needed to work around https://sourceware.org/bugzilla/show_bug.cgi?id=27490 Differential Revision: https://reviews.llvm.org/D97648
Can you clarify which conflicting versions are in play here? |
The compiler-rt in Rust right now vs lld @ main. It turns out there are more backports to do so we can enable linker GC with coverage enabled, which helps fix the very high RAM usage. Doing all of them may not be worth it. I'm working on finding out if this change is worth it on its own.. |
Got feedback from @tmandry and @petrhosek that this isn't going to be sufficient on its own. Going to close this out for the time being. |
Add pass for splitting blocks after calls.
Cherry pick of three changes that fix an incompatibility between recent lld versions and compiler-rt runtime used by rust that was causing
ld.lld: error: undefined hidden symbol: __start__llvm_prf_data
errors.cc @petrhosek @tmandry