Skip to content
13 changes: 9 additions & 4 deletions system/lib/libcxxabi/src/cxa_exception_emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
#include <stdint.h>
#include <stdlib.h>

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

// TODO: Remove this when Rust doesn't need it anymore.
#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.
// 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,
Expand All @@ -27,6 +28,10 @@ __gxx_personality_v0(int version,
_Unwind_Context* context) {
abort();
}
#endif // !defined(__USING_WASM_EXCEPTIONS__)

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

using namespace __cxxabiv1;

Expand Down
15 changes: 2 additions & 13 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12157,7 +12157,7 @@ def test_print_map(self):
self.assertEqual(out, out2)

def test_rust_gxx_personality_v0(self):
create_file('main.cpp', r'''
self.do_run(r'''
#include <stdio.h>
#include <stdint.h>
extern "C" {
Expand All @@ -12167,15 +12167,4 @@ def test_rust_gxx_personality_v0(self):
return 0;
}
}
''')
self.run_process([EMXX, '-c', 'main.cpp', '-fexceptions'])

self.run_process([EMXX, '-o', 'main.js', 'main.o', '-fexceptions'] + self.get_emcc_args())

try:
self.do_run('main.js', no_build=True)
raise RuntimeError('should not have passed')
except AssertionError as e:
err = e
assert "Aborted(native code called abort())" in err.args[0]
del err
''', 'Aborted(native code called abort())', assert_returncode=NON_ZERO)
1 change: 0 additions & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,6 @@ def get_files(self):
'private_typeinfo.cpp',
'cxa_exception_emscripten.cpp',
]
print("HI!")
if self.eh_mode == Exceptions.NONE:
filenames += ['cxa_noexception.cpp']
elif self.eh_mode == Exceptions.WASM:
Expand Down