Skip to content

Commit 28020ed

Browse files
authored
Add back in __gxx_personality_v0 (#17222)
1 parent ccc97cd commit 28020ed

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

system/lib/libcxxabi/src/cxa_exception_emscripten.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@
1111
#include "cxa_exception.h"
1212
#include "private_typeinfo.h"
1313
#include <stdio.h>
14+
#include <stdint.h>
15+
#include <stdlib.h>
16+
17+
#if !defined(__USING_WASM_EXCEPTIONS__)
18+
// Until recently, Rust's `rust_eh_personality` for emscripten referred to this
19+
// symbol. If Emscripten doesn't provide it, there will be errors when linking
20+
// rust. The rust personality function is never called so we can just abort.
21+
// We need this to support old versions of Rust.
22+
// https://github.com/rust-lang/rust/pull/97888
23+
// TODO: Remove this when Rust doesn't need it anymore.
24+
extern "C" _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
25+
__gxx_personality_v0(int version,
26+
_Unwind_Action actions,
27+
uint64_t exceptionClass,
28+
_Unwind_Exception* unwind_exception,
29+
_Unwind_Context* context) {
30+
abort();
31+
}
32+
#endif // !defined(__USING_WASM_EXCEPTIONS__)
1433

1534
#if defined(__USING_EMSCRIPTEN_EXCEPTIONS__) || \
1635
defined(__USING_WASM_EXCEPTIONS__)

tests/test_other.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12204,3 +12204,16 @@ def test_print_map(self):
1220412204
self.assertContained('hello_world.o:(__original_main)', out)
1220512205
out2 = self.run_process([EMCC, 'hello_world.o', '-Wl,-M'], stdout=PIPE).stdout
1220612206
self.assertEqual(out, out2)
12207+
12208+
def test_rust_gxx_personality_v0(self):
12209+
self.do_run(r'''
12210+
#include <stdio.h>
12211+
#include <stdint.h>
12212+
extern "C" {
12213+
int __gxx_personality_v0(int version, void* actions, uint64_t exception_class, void* exception_object, void* context);
12214+
int main() {
12215+
__gxx_personality_v0(0, NULL, 0, NULL, NULL);
12216+
return 0;
12217+
}
12218+
}
12219+
''', assert_returncode=NON_ZERO)

0 commit comments

Comments
 (0)