[llvm] [llvm] Allow Rust personality name to contain arbitrary prefix (PR #166095)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 10:46:30 PST 2025
https://github.com/Noratrieb updated https://github.com/llvm/llvm-project/pull/166095
>From b0f36bcb896948b702347909832425d644ea52f9 Mon Sep 17 00:00:00 2001
From: Noratrieb <git at noratrieb.dev>
Date: Sun, 2 Nov 2025 20:00:50 +0100
Subject: [PATCH] [llvm] Allow Rust personality name to contain arbitrary
prefix
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`).
---
llvm/lib/IR/EHPersonalities.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/IR/EHPersonalities.cpp b/llvm/lib/IR/EHPersonalities.cpp
index 9297a82e7d2b0..12ae4748e1f4a 100644
--- a/llvm/lib/IR/EHPersonalities.cpp
+++ b/llvm/lib/IR/EHPersonalities.cpp
@@ -47,7 +47,8 @@ EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
.Case("__C_specific_handler", EHPersonality::MSVC_TableSEH)
.Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
.Case("ProcessCLRException", EHPersonality::CoreCLR)
- .Case("rust_eh_personality", EHPersonality::Rust)
+ // Rust mangles its personality function, so we can't test exact equality.
+ .EndsWith("rust_eh_personality", EHPersonality::Rust)
.Case("__gxx_wasm_personality_v0", EHPersonality::Wasm_CXX)
.Case("__xlcxx_personality_v1", EHPersonality::XL_CXX)
.Case("__zos_cxx_personality_v2", EHPersonality::ZOS_CXX)
@@ -77,7 +78,8 @@ StringRef llvm::getEHPersonalityName(EHPersonality Pers) {
case EHPersonality::CoreCLR:
return "ProcessCLRException";
case EHPersonality::Rust:
- return "rust_eh_personality";
+ llvm_unreachable(
+ "Cannot get personality name of Rust personality, since it is mangled");
case EHPersonality::Wasm_CXX:
return "__gxx_wasm_personality_v0";
case EHPersonality::XL_CXX:
More information about the llvm-commits
mailing list