diff --git a/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp b/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp index facc0b8ef50c2..4e971db9307b4 100644 --- a/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp +++ b/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp @@ -11,6 +11,25 @@ #include "cxa_exception.h" #include "private_typeinfo.h" #include +#include +#include + +#if !defined(__USING_WASM_EXCEPTIONS__) +// Until recently, Rust's `rust_eh_personality` for emscripten referred to this +// symbol. If Emscripten doesn't provide it, there will be errors when linking +// rust. The rust personality function is never called so we can just abort. +// We need this to support old versions of Rust. +// https://github.com/rust-lang/rust/pull/97888 +// TODO: Remove this when Rust doesn't need it anymore. +extern "C" _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code +__gxx_personality_v0(int version, + _Unwind_Action actions, + uint64_t exceptionClass, + _Unwind_Exception* unwind_exception, + _Unwind_Context* context) { + abort(); +} +#endif // !defined(__USING_WASM_EXCEPTIONS__) #if defined(__USING_EMSCRIPTEN_EXCEPTIONS__) || \ defined(__USING_WASM_EXCEPTIONS__) diff --git a/tests/test_other.py b/tests/test_other.py index cee88aeb73cec..d00c3fa62e5b8 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -12155,3 +12155,16 @@ def test_print_map(self): self.assertContained('hello_world.o:(__original_main)', out) out2 = self.run_process([EMCC, 'hello_world.o', '-Wl,-M'], stdout=PIPE).stdout self.assertEqual(out, out2) + + def test_rust_gxx_personality_v0(self): + self.do_run(r''' + #include + #include + extern "C" { + int __gxx_personality_v0(int version, void* actions, uint64_t exception_class, void* exception_object, void* context); + int main() { + __gxx_personality_v0(0, NULL, 0, NULL, NULL); + return 0; + } + } + ''', assert_returncode=NON_ZERO)