Backport coverage fixes#108
Closed
Nashenas88 wants to merge 3 commits intorust-lang:rustc/12.0-2021-04-15from
Closed
Backport coverage fixes#108Nashenas88 wants to merge 3 commits intorust-lang:rustc/12.0-2021-04-15from
Nashenas88 wants to merge 3 commits intorust-lang:rustc/12.0-2021-04-15from
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
Member
Can you clarify which conflicting versions are in play here? |
Member
|
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.. |
Author
|
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. |
vext01
pushed a commit
to vext01/llvm-project
that referenced
this pull request
Dec 11, 2023
Add pass for splitting blocks after calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_dataerrors.cc @petrhosek @tmandry