-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
ld64.lld: error: too many personalities (4) for compact unwind to encode #58277
Comments
@llvm/issue-subscribers-lld-macho |
Interesting. I believe @oontvoo saw something similar recently too. ld64 also emits 3 personality entries for arm64. It appears that it links in |
I think this also needs a longer term "fix". That is, 2-bit (but 0 is already reserved) isn't going to be enough. (There are at least 3 common personalities: ___gxx_personality_v0, ___gcc_personality_v0, ___objc_personality_v0 already. Now with rust, it's 4) |
@oontvoo I don't think ld64 supports encoding 4 (distinct) personalities either, so we're fine on that front. Simple repro: https://gist.github.com/int3/7235eb5a7266b3712b055805e3cea634 |
Okay I figured this out. Our personality-dedup logic doesn't account for personalities encoded in EH frames. That also explains why it wasn't an issue in LLVM 14 -- we already had support for compact unwinds then, but not for EH frames. So the personalities in the EH frames were ignored. |
Also note that the initial test case likely didn't repro the error on x86_64-apple-darwin because different relocations were chosen by MC. Without section relocs in compact unwind, this issue will not repro. However, it is nonetheless possible to construct inputs for x86_64 that cause it to emit those relocs and trigger this issue. In fact, the test in the aforementioned diff targets x86_64. |
/cherry-pick 7b45dfc |
Error: Command failed due to missing milestone. |
/cherry-pick 7b45dfc |
/branch llvm/llvm-project-release-prs/issue58277 |
/pull-request llvm/llvm-project-release-prs#188 |
Should the PR be added to the next milestone, since it didn't make the cut for 15.0.3? |
@tstellar how can I make sure this gets into the next patch release? I'd thought creating the PR would be enough... |
Reopening so we don't miss pulling this into 15.0.4 :) |
CC @tru, who's been running this release. 15.0.4 wasn't planned originally but we're getting it now: https://discourse.llvm.org/t/llvm-15-0-4-release-schedule-update/66099 |
Yep thanks - I was chatting with @int3 over at discord :) |
We already do this for personality pointers referenced from compact unwind entries; this patch extends that behavior to personalities referenced via EH frames as well. This reduces the number of distinct personalities we need in the final binary, and helps us avoid hitting the "too many personalities" error. I renamed `UnwindInfoSection::prepareRelocations()` to simply `prepare` since we now do some non-reloc-specific stuff within. Fixes #58277. Reviewed By: #lld-macho, oontvoo Differential Revision: https://reviews.llvm.org/D135728 (cherry picked from commit 7b45dfc)
(Largely a copy/paste from rust-lang/rust#102754)
When mixing ObjC, C++ and Rust in the same binary on aarch64-apple-darwin targets (e.g. like in Firefox), lld from LLVM 15 complains about "too many personalities". This does not happen with lld from LLVM 14 because AIUI it had limited support for compact unwind info (or no support at all). This does not happen with ld64.
For some reason, since rust-lang/rust#92845, this code in lld is hit:
llvm-project/lld/MachO/UnwindInfoSection.cpp
Line 300 in d30dccd
Ultimately, this leads to
llvm-project/lld/MachO/UnwindInfoSection.cpp
Line 378 in d30dccd
where there are 4 personalities instead of 3:
___objc_personality_v0
,___gxx_personality_v0
,_rust_eh_personality
<internal>
With previous rust versions, only the first three ones would be there. It looks like the relocation that triggers the
<internal>
is related to therust_eh_personality
function inlibrary/std/src/personality/gcc.rs
itself.STR:
bar.cc
file with content:foo.m
file with content:qux.rs
file with content:Makefile
file with content:$PATH
.$PATH
.SDKROOT
to point to a macOS SDKmake
This does not happen on x86_64-apple-darwin, but interestingly the list of personalities there is:
___objc_personality_v0
,___gxx_personality_v0
,<internal>
(no
_rust_eh_personality
).The text was updated successfully, but these errors were encountered: