Skip to content

Commit 2ecbdc1

Browse files
committed
Don't use __gxx_personality_v0 in panic_unwind on emscripten target
This resolves #85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
1 parent 1a97162 commit 2ecbdc1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/panic_unwind/src/emcc.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void {
105105
}
106106
}
107107

108+
109+
// This is required by the compiler to exist (e.g., it's a lang item), but it's
110+
// never actually called by the compiler. Emscripten EH doesn't use a
111+
// personality function at all, it instead uses __cxa_find_matching_catch.
112+
// Wasm error handling would use __gxx_personality_wasm0.
108113
#[lang = "eh_personality"]
109114
unsafe extern "C" fn rust_eh_personality(
110115
version: c_int,
@@ -113,7 +118,7 @@ unsafe extern "C" fn rust_eh_personality(
113118
exception_object: *mut uw::_Unwind_Exception,
114119
context: *mut uw::_Unwind_Context,
115120
) -> uw::_Unwind_Reason_Code {
116-
__gxx_personality_v0(version, actions, exception_class, exception_object, context)
121+
core::intrinsics::abort()
117122
}
118123

119124
extern "C" {

0 commit comments

Comments
 (0)