Repository navigation
Mangle personality symbol - #148413
Merged
rust-bors[bot] merged 1 commit intoOct 15, 2026
Merged
Mangle personality symbol#148413
Conversation
Collaborator
|
Some changes occurred in compiler/rustc_codegen_ssa |
Noratrieb
marked this pull request as draft
November 2, 2025 20:29
This comment has been minimized.
This comment has been minimized.
Member
|
re: LLVM version-detection, do you mean |
This comment was marked as resolved.
This comment was marked as resolved.
rnk
pushed a commit
to llvm/llvm-project
that referenced
this pull request
Nov 8, 2025
LLVM needs to figure out the type of EH personality for various reasons. To do this, it currently matches against a hardcoded list of names. In Rust, we would like to mangle our personality function to better support linking multiple Rust standard libraries via staticlib. We have currently mangled all symbols except the personality, which remains unmangled because of this LLVM hardcoding. Instead, this now does a suffix match of the personality name, which will work with the mangling scheme used for these internal symbols (e.g. `_RNvCseCSg29WUqSe_7___rustc12___rust_alloc`). Companion Rust PR: rust-lang/rust#148413
llvm-sync Bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Nov 8, 2025
…efix (#166095) LLVM needs to figure out the type of EH personality for various reasons. To do this, it currently matches against a hardcoded list of names. In Rust, we would like to mangle our personality function to better support linking multiple Rust standard libraries via staticlib. We have currently mangled all symbols except the personality, which remains unmangled because of this LLVM hardcoding. Instead, this now does a suffix match of the personality name, which will work with the mangling scheme used for these internal symbols (e.g. `_RNvCseCSg29WUqSe_7___rustc12___rust_alloc`). Companion Rust PR: rust-lang/rust#148413
Noratrieb
force-pushed
the
mangle-rust-eh-personality
branch
from
January 31, 2026 15:00
f98da1c to
9ea88e3
Compare
This comment has been minimized.
This comment has been minimized.
Noratrieb
force-pushed
the
mangle-rust-eh-personality
branch
from
January 31, 2026 15:31
9ea88e3 to
15d0368
Compare
Noratrieb
force-pushed
the
mangle-rust-eh-personality
branch
2 times, most recently
from
January 31, 2026 15:42
78ccd7b to
e9c966b
Compare
Noratrieb
commented
Jan 31, 2026
This comment has been minimized.
This comment has been minimized.
Noratrieb
force-pushed
the
mangle-rust-eh-personality
branch
from
January 31, 2026 16:38
e9c966b to
ee860b6
Compare
This comment has been minimized.
This comment has been minimized.
Noratrieb
force-pushed
the
mangle-rust-eh-personality
branch
from
January 31, 2026 19:38
ee860b6 to
a74a260
Compare
This comment has been minimized.
This comment has been minimized.
Noratrieb
force-pushed
the
mangle-rust-eh-personality
branch
from
January 31, 2026 20:28
a74a260 to
f0f210f
Compare
Member
|
Yes it can. Such code has been using unstable implementation details either way. We would just start requiring that the no_std projects acknowledge this. In any case if you are compiling for a no_std target, then the standard library would already be compiled with panic=abort and no personality function would be needed unless you use |
Contributor
|
@bors r+ |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 15, 2026
…uwer Rollup of 14 pull requests Successful merges: - #163132 (Test panics and wasm32-wasip3 in CI, not wasip1) - #164314 (Abby: use a smallvec for `And`/`Or` constraints) - #148413 (Mangle personality symbol) - #163688 (Add aarch64-unknown-qtee as a tier 3 target) - #164076 (Fix ICE when move expressions reference out-of-scope local bindings) - #164327 ([coff] Symbol renaming stored the original name, not the undecorated name) - #162432 (Improve diagnostics for non-well-formed associated items) - #164138 (cg_llvm: Use a callback to enforce scoped lifetimes in ModuleLlvm ) - #164210 (`incomplete` -> `unstable` for delegation feature) - #164225 (Point at assoc item for trait that needs to be implemented) - #164278 (Output remapped paths in rustdoc JSON with the `documentation` scope) - #164308 (format abby dsl errors better) - #164335 (expand and document tool attribute shadowing test) - #164342 (Use regular type parsing for argument-position const parameters)
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 15, 2026
Rollup merge of #148413 - Noratrieb:mangle-rust-eh-personality, r=petrochenkov Mangle personality symbol Previously, std-internal symbols (like `__rust_alloc` or `rust_panic`) were changed to now be mangled via a v0 scheme with the compiler version hash (`_RNvCs4CIB29Id3dw_7___rustc10rust_panic`) to make it possible to have multiple staticlibs (as long as they have different version hashes) in the same program without symbol conflicts. But the personality function remained unmangled, because LLVM hardcodes that name. I made a change in LLVM llvm/llvm-project#166095 that makes LLVM now check the suffix instead of an exact match, so we can mangle the personality function with this scheme. This removes the last completely unmangled symbol from Rust staticlibs! (though the mangling is still quite weak, so it's still not as nice as it would ideally be). Before, on a trivial staticlib: ``` readelf -s liblib.a | rg GLOBAL | rg -v " UND | HIDDEN " | rg -v ' _ZN' 8: 0000000000000000 5 FUNC GLOBAL DEFAULT 3 _RNvCseCSg29WUqSe_7___rustc12___rust_alloc 10: 0000000000000000 5 FUNC GLOBAL DEFAULT 5 _RNvCseCSg29WUqSe_7___rustc14___rust_dealloc 12: 0000000000000000 5 FUNC GLOBAL DEFAULT 7 _RNvCseCSg29WUqSe_7___rustc14___rust_realloc 14: 0000000000000000 5 FUNC GLOBAL DEFAULT 9 _RNvCseCSg29WUqSe_7___rustc19___rust_alloc_zeroed 16: 0000000000000000 3 FUNC GLOBAL DEFAULT 11 _RNvCseCSg29WUqSe_7___rustc42___rust_alloc_error_handler_should_panic_v2 17: 0000000000000000 1 FUNC GLOBAL DEFAULT 12 _RNvCseCSg29WUqSe_7___rustc35___rust_no_alloc_shim_is_unstable_v2 3383: 0000000000000000 111 FUNC GLOBAL DEFAULT 5 _RNvCseCSg29WUqSe_7___rustc10rust_panic 3387: 0000000000000000 93 FUNC GLOBAL DEFAULT 7 _RNvCseCSg29WUqSe_7___rustc11___rdl_alloc 3390: 0000000000000000 10 FUNC GLOBAL DEFAULT 9 _RNvCseCSg29WUqSe_7___rustc12___rust_abort 3391: 0000000000000000 6 FUNC GLOBAL DEFAULT 11 _RNvCseCSg29WUqSe_7___rustc13___rdl_dealloc 3393: 0000000000000000 167 FUNC GLOBAL DEFAULT 13 _RNvCseCSg29WUqSe_7___rustc13___rdl_realloc 3396: 0000000000000000 203 FUNC GLOBAL DEFAULT 15 _RNvCseCSg29WUqSe_7___rustc17___rust_drop_panic 3399: 0000000000000000 29 FUNC GLOBAL DEFAULT 18 _RNvCseCSg29WUqSe_7___rustc17rust_begin_unwind 3401: 0000000000000000 140 FUNC GLOBAL DEFAULT 20 _RNvCseCSg29WUqSe_7___rustc18___rdl_alloc_zeroed 3404: 0000000000000000 203 FUNC GLOBAL DEFAULT 22 _RNvCseCSg29WUqSe_7___rustc24___rust_foreign_exception 3405: 0000000000000000 19 FUNC GLOBAL DEFAULT 25 _RNvCseCSg29WUqSe_7___rustc26___rust_alloc_error_handler 4410: 0000000000000000 1471 FUNC GLOBAL DEFAULT 2752 rust_eh_personality 25: 0000000000000000 161 FUNC GLOBAL DEFAULT 5 _RNvCseCSg29WUqSe_7___rustc18___rust_start_panic 32: 0000000000000000 82 FUNC GLOBAL DEFAULT 8 _RNvCseCSg29WUqSe_7___rustc20___rust_panic_cleanup 249: 0000000000000000 182 FUNC GLOBAL DEFAULT 5 _RNvCseCSg29WUqSe_7___rustc25___rdl_alloc_error_handler 3: 0000000000000000 57 FUNC GLOBAL DEFAULT 3 _RNvCseCSg29WUqSe_7___rustc17___rust_probestack ``` After: ``` 8: 0000000000000000 5 FUNC GLOBAL DEFAULT 3 _RNvCs4CIB29Id3dw_7___rustc12___rust_alloc 10: 0000000000000000 5 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc14___rust_dealloc 12: 0000000000000000 5 FUNC GLOBAL DEFAULT 7 _RNvCs4CIB29Id3dw_7___rustc14___rust_realloc 14: 0000000000000000 5 FUNC GLOBAL DEFAULT 9 _RNvCs4CIB29Id3dw_7___rustc19___rust_alloc_zeroed 16: 0000000000000000 3 FUNC GLOBAL DEFAULT 11 _RNvCs4CIB29Id3dw_7___rustc42___rust_alloc_error_handler_should_panic_v2 17: 0000000000000000 1 FUNC GLOBAL DEFAULT 12 _RNvCs4CIB29Id3dw_7___rustc35___rust_no_alloc_shim_is_unstable_v2 422: 0000000000000000 19 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc26___rust_alloc_error_handler 429: 0000000000000000 308 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc19rust_eh_personality 349: 0000000000000000 10 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc12___rust_abort 164: 0000000000000000 93 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc11___rdl_alloc 167: 0000000000000000 11 FUNC GLOBAL DEFAULT 7 _RNvCs4CIB29Id3dw_7___rustc13___rdl_dealloc 169: 0000000000000000 167 FUNC GLOBAL DEFAULT 9 _RNvCs4CIB29Id3dw_7___rustc13___rdl_realloc 172: 0000000000000000 140 FUNC GLOBAL DEFAULT 11 _RNvCs4CIB29Id3dw_7___rustc18___rdl_alloc_zeroed 688: 0000000000000000 106 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc10rust_panic 693: 0000000000000000 207 FUNC GLOBAL DEFAULT 7 _RNvCs4CIB29Id3dw_7___rustc17___rust_drop_panic 696: 0000000000000000 29 FUNC GLOBAL DEFAULT 10 _RNvCs4CIB29Id3dw_7___rustc17rust_begin_unwind 698: 0000000000000000 207 FUNC GLOBAL DEFAULT 12 _RNvCs4CIB29Id3dw_7___rustc24___rust_foreign_exception 26: 0000000000000000 161 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc18___rust_start_panic 33: 0000000000000000 82 FUNC GLOBAL DEFAULT 8 _RNvCs4CIB29Id3dw_7___rustc20___rust_panic_cleanup 88: 0000000000000000 182 FUNC GLOBAL DEFAULT 5 _RNvCs4CIB29Id3dw_7___rustc25___rdl_alloc_error_handler 3: 0000000000000000 57 FUNC GLOBAL DEFAULT 3 _RNvCs4CIB29Id3dw_7___rustc17___rust_probestack ``` r? bjorn3
This was referenced Oct 17, 2026
schungx
pushed a commit
to rhaiscript/rhai
that referenced
this pull request
Oct 17, 2026
Since rust-lang/rust#148413 (in nightly 2026-10-16) the compiler mangles the personality symbol like the other std-internal symbols, so the pre-built `core`/`alloc` now reference `__rustc::rust_eh_personality` and the `#[no_mangle] extern "C" fn rust_eh_personality()` in no_std_test no longer satisfies the linker: error: linking with `cc` failed = note: Undefined symbols for architecture arm64: "__RNvCs6EUDi8WbMwz_7___rustc19rust_eh_personality" Every NoStdBuild job has failed with this since that nightly, on every branch. Declare the function as `#[lang = "eh_personality"]` instead (with `#![feature(lang_items)]`), the shape rust-lang/rust's own no_std binary fixture (tests/run-make/no-alloc-shim/foo.rs) moved to in that PR. The compiler then emits the symbol under whatever name it expects, so this builds on the nightlies before and after the change. The routine is still never called: every profile sets `panic = "abort"`. Built with nightly 2026-10-16 (fails without this change) and nightly 2026-10-09 (builds either way), `--profile unix` and `--profile macos`.
antoyo
pushed a commit
to rust-lang/rustc_codegen_gcc
that referenced
this pull request
Oct 19, 2026
…uwer Rollup of 14 pull requests Successful merges: - rust-lang/rust#163132 (Test panics and wasm32-wasip3 in CI, not wasip1) - rust-lang/rust#164314 (Abby: use a smallvec for `And`/`Or` constraints) - rust-lang/rust#148413 (Mangle personality symbol) - rust-lang/rust#163688 (Add aarch64-unknown-qtee as a tier 3 target) - rust-lang/rust#164076 (Fix ICE when move expressions reference out-of-scope local bindings) - rust-lang/rust#164327 ([coff] Symbol renaming stored the original name, not the undecorated name) - rust-lang/rust#162432 (Improve diagnostics for non-well-formed associated items) - rust-lang/rust#164138 (cg_llvm: Use a callback to enforce scoped lifetimes in ModuleLlvm ) - rust-lang/rust#164210 (`incomplete` -> `unstable` for delegation feature) - rust-lang/rust#164225 (Point at assoc item for trait that needs to be implemented) - rust-lang/rust#164278 (Output remapped paths in rustdoc JSON with the `documentation` scope) - rust-lang/rust#164308 (format abby dsl errors better) - rust-lang/rust#164335 (expand and document tool attribute shadowing test) - rust-lang/rust#164342 (Use regular type parsing for argument-position const parameters)
bjorn3
pushed a commit
to rust-lang/rustc_codegen_cranelift
that referenced
this pull request
Oct 19, 2026
…uwer Rollup of 14 pull requests Successful merges: - rust-lang/rust#163132 (Test panics and wasm32-wasip3 in CI, not wasip1) - rust-lang/rust#164314 (Abby: use a smallvec for `And`/`Or` constraints) - rust-lang/rust#148413 (Mangle personality symbol) - rust-lang/rust#163688 (Add aarch64-unknown-qtee as a tier 3 target) - rust-lang/rust#164076 (Fix ICE when move expressions reference out-of-scope local bindings) - rust-lang/rust#164327 ([coff] Symbol renaming stored the original name, not the undecorated name) - rust-lang/rust#162432 (Improve diagnostics for non-well-formed associated items) - rust-lang/rust#164138 (cg_llvm: Use a callback to enforce scoped lifetimes in ModuleLlvm ) - rust-lang/rust#164210 (`incomplete` -> `unstable` for delegation feature) - rust-lang/rust#164225 (Point at assoc item for trait that needs to be implemented) - rust-lang/rust#164278 (Output remapped paths in rustdoc JSON with the `documentation` scope) - rust-lang/rust#164308 (format abby dsl errors better) - rust-lang/rust#164335 (expand and document tool attribute shadowing test) - rust-lang/rust#164342 (Use regular type parsing for argument-position const parameters)
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this pull request
Oct 19, 2026
…uwer Rollup of 14 pull requests Successful merges: - rust-lang/rust#163132 (Test panics and wasm32-wasip3 in CI, not wasip1) - rust-lang/rust#164314 (Abby: use a smallvec for `And`/`Or` constraints) - rust-lang/rust#148413 (Mangle personality symbol) - rust-lang/rust#163688 (Add aarch64-unknown-qtee as a tier 3 target) - rust-lang/rust#164076 (Fix ICE when move expressions reference out-of-scope local bindings) - rust-lang/rust#164327 ([coff] Symbol renaming stored the original name, not the undecorated name) - rust-lang/rust#162432 (Improve diagnostics for non-well-formed associated items) - rust-lang/rust#164138 (cg_llvm: Use a callback to enforce scoped lifetimes in ModuleLlvm ) - rust-lang/rust#164210 (`incomplete` -> `unstable` for delegation feature) - rust-lang/rust#164225 (Point at assoc item for trait that needs to be implemented) - rust-lang/rust#164278 (Output remapped paths in rustdoc JSON with the `documentation` scope) - rust-lang/rust#164308 (format abby dsl errors better) - rust-lang/rust#164335 (expand and document tool attribute shadowing test) - rust-lang/rust#164342 (Use regular type parsing for argument-position const parameters)
tgross35
added a commit
to tgross35/compiler-builtins
that referenced
this pull request
Oct 20, 2026
Since [1], these symbols are now mangled so need a lang item indicator rather than `unsafe(no_mangle)`. It seems like we can build without the other `rust_eh` symbols nowadays as well. [1]: rust-lang/rust#148413
tgross35
added a commit
to tgross35/compiler-builtins
that referenced
this pull request
Oct 20, 2026
Since [1], these symbols are now mangled so need a lang item indicator rather than `unsafe(no_mangle)`. This works on all platforms. It seems like we can build without the other `rust_eh` symbols nowadays as well. [1]: rust-lang/rust#148413
tgross35
added a commit
to rust-lang/compiler-builtins
that referenced
this pull request
Oct 20, 2026
Since [1], these symbols are now mangled so need a lang item indicator rather than `unsafe(no_mangle)`. This works on all platforms. It seems like we can build without the other `rust_eh` symbols nowadays as well. [1]: rust-lang/rust#148413
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Oct 24, 2026
…k-Simulacrum Stop mangling rust_eh_personality again for now Some projects manually define rust_eh_personality as they use no_std on a target where libcore is compiled with panic=unwind and thus need rust_eh_personality to be present while it is only defined in libstd. These projects don't want to use unstable features and thus can't use a proper #[lang = "eh_personality"]. This reverts just the symbol mangling change of rust-lang#148413. It preserves all the refactors to prevent codegen backends from hard coding the symbol name, so we can easily change it back to mangled in the future again.
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 24, 2026
Rollup merge of #164855 - bjorn3:unmangle_personality, r=Mark-Simulacrum Stop mangling rust_eh_personality again for now Some projects manually define rust_eh_personality as they use no_std on a target where libcore is compiled with panic=unwind and thus need rust_eh_personality to be present while it is only defined in libstd. These projects don't want to use unstable features and thus can't use a proper #[lang = "eh_personality"]. This reverts just the symbol mangling change of #148413. It preserves all the refactors to prevent codegen backends from hard coding the symbol name, so we can easily change it back to mangled in the future again.
tgross35
added a commit
to tgross35/rust
that referenced
this pull request
Oct 27, 2026
Since [1], these symbols are now mangled so need a lang item indicator rather than `unsafe(no_mangle)`. This works on all platforms. It seems like we can build without the other `rust_eh` symbols nowadays as well. [1]: rust-lang#148413
bherrera
pushed a commit
to misttech/fuchsia
that referenced
this pull request
Nov 5, 2026
rust-lang/rust#148413 mangles rust_eh_personality with a compiler-version hash under __rustc, so passing -defsym=rust_eh_personality=0 on the linker command line no longer satisfies references from prebuilt libcore when building rust-basic for host. Disable the rust-basic load test on non-Fuchsia targets until rust_eh_personality handling is resolved. Bug: 581073414 Change-Id: I689bbffa85b2038ca272f2277c7bf6219df995ba Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1942298 Fuchsia-Auto-Submit: Gulfem Savrun <gulfem@google.com> Risk: Fuchsia CL Risk (Advisory) <groupagent-fuchsia-risk@google.com> Reviewed-by: Paul Kirth <paulkirth@google.com> Commit-Queue: Gulfem Savrun <gulfem@google.com> Reviewed-by: Roland McGrath <mcgrathr@google.com>
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.
View all comments
Previously, std-internal symbols (like
__rust_allocorrust_panic) were changed to now be mangled via a v0 scheme with the compiler version hash (_RNvCs4CIB29Id3dw_7___rustc10rust_panic) to make it possible to have multiple staticlibs (as long as they have different version hashes) in the same program without symbol conflicts. But the personality function remained unmangled, because LLVM hardcodes that name.I made a change in LLVM llvm/llvm-project#166095 that makes LLVM now check the suffix instead of an exact match, so we can mangle the personality function with this scheme.
This removes the last completely unmangled symbol from Rust staticlibs! (though the mangling is still quite weak, so it's still not as nice as it would ideally be).
Before, on a trivial staticlib:
After:
r? bjorn3