[PATCH] D15781: [compiler-rt] Add support for ARM EHABI to gcc_personality_v0.
Timon Van Overveldt via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 27 16:04:26 PST 2015
timonvo added a comment.
In http://reviews.llvm.org/D15781#317171, @compnerd wrote:
> I don't understand how this works or is correct. The personality does NOT support EHABI. What is the intent for changing this? We shouldn't be generating references to this personality in EHABI AFAIK.
Thanks for the quick reply. First off, let me be clear that I'm no expert on personality routines, nor the ARM EHABI spec, so if I the following does not make any sense please do tell me.
I'm trying to make Rust (https://github.com/rust-lang/rust) support producing fully statically linked ARM binaries by linking against MUSL libc (and without linking libgcc) on ARM. Because Rust's exception/unwinding semantics conveniently match C's, it leverages C's personality routine instead of building its own (see https://github.com/timonvo/rust/blob/64b90f81c3ec2cf5564ed8456d836516491b9d01/src/libstd/sys/common/unwind/gcc.rs#L58). For dynamically linked binaries it relies on libgcc's personality routine implementation, but in order to avoid libgcc with MUSL libc, I want to use the personality routine defined by compiler-rt instead. That' where the reference to this PR on ARM EHABI would come from.
As you correctly stated, I believe the personality routine definitely does not support ARM EHABI in its current state. I do believe however, that my changes should make it correctly support it. I've read the ARM EHABI spec, as well as looked at GCC's implementation of the C personality routine on ARM EHABI. AFAICT, the main difference between an ARM EHABI PR and a regular Dwarf-based PR is that ARM EHABI expects the PR to unwind the stack before continuing. In fact, I believe most differences lie in the actual unwinding layer, and that those are all already handled in libunwind's EHABI implementation.
I believe that the format of the language-specific data is still the same for both types of exceptions, and hence, the remainder of the code in the personality routine can be preserved/reused. Because LLVM's libunwind already stores all the information it needs in the context variable, we don't even have to preserve or store somewhere the "exceptionObject" like GCC's personality routine does (https://github.com/gcc-mirror/gcc/blob/d353bf189d2bbaf4059f402ee4d2a5ea074c349f/libgcc/unwind-c.c#L141). That link also shows GCC's implementation, and I believe it supports my interpretation of things.
However LLVM just does not want to add support for EHABI in this personality routine because it itself would not normally emit references to it, then perhaps I'll have to land these changes downstream in Rust's copy. I was hoping to avoid that though.
@logan: I plan to address your comments soon. Thanks for the swift reply!
P.S.: I believe that https://github.com/rust-lang/compiler-rt/commit/b6087e82ba1384c4af3adf2dc68e92316f0d4caf also indicates that the current implementation is broken for SJLJ-based exceptions.
More information about the llvm-commits