Description
(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 the rust_eh_personality
function in library/std/src/personality/gcc.rs
itself.
STR:
- Create a
bar.cc
file with content:
#include <stdexcept>
extern "C" void qux();
void bar() { qux(); throw std::runtime_error("foo"); }
- Create a
foo.m
file with content:
void foo() { @try {} @finally {} }
- Create a
qux.rs
file with content:
#![crate_type = "staticlib"]
extern "C" {
fn foo();
}
#[no_mangle]
pub unsafe extern "C" fn qux() {
println!("foo");
foo();
}
- Create a
Makefile
file with content:
TARGET = --target=aarch64-apple-darwin
lib.dylib: bar.o foo.o libqux.a
clang++ -o $@ $^ -fuse-ld=lld -dynamiclib $(TARGET) -lobjc
bar.o: bar.cc
clang++ -o $@ -c $^ $(TARGET)
foo.o: foo.m
clang -o $@ -c $^ $(TARGET)
libqux.a: qux.rs
rustc $^ $(TARGET)
- Get clang 15 + lld and make sure it's in your
$PATH
. - Get rustc beta and make sure it's in your
$PATH
. - Set
SDKROOT
to point to a macOS SDK - Run
make
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
).
Metadata
Metadata
Assignees
Type
Projects
Status