Skip to content

Commit 228af1a

Browse files
authored
[EH] Guard destructor changes in libc++abi with __wasm__ (emscripten-core#21974)
These changes are due to that Wasm destructor returns its argument, so in case someone wants to compile out libc++abi _without_ using Wasm EH, these will error out too. In Emscripten this has been fine because in `system_lib.py` we only build these files when Wasm EH is enabled, but this may not be the case if we upstream our changes.
1 parent f969e30 commit 228af1a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

system/lib/libcxxabi/include/cxxabi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB
5858
// 2.4.3 Throwing the Exception Object
5959
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
6060
__cxa_throw(void *thrown_exception, std::type_info *tinfo,
61-
#ifdef __WASM_EXCEPTIONS__
61+
#ifdef __wasm__
6262
void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
6363
#else
6464
void (_LIBCXXABI_DTOR_FUNC *dest)(void *));

system/lib/libcxxabi/src/cxa_exception.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void __cxa_free_exception(void *thrown_object) throw() {
207207
}
208208

209209
__cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo,
210-
#ifdef __WASM_EXCEPTIONS__
210+
#ifdef __wasm__
211211
// In Wasm, a destructor returns its argument
212212
void *(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
213213
#else
@@ -279,7 +279,7 @@ void __throw_exception_with_stack_trace(_Unwind_Exception*);
279279
#endif
280280

281281
void
282-
#ifdef __WASM_EXCEPTIONS__
282+
#ifdef __wasm__
283283
// In Wasm, a destructor returns its argument
284284
__cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
285285
#else

system/lib/libcxxabi/src/cxa_exception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
6363

6464
// Manage the exception object itself.
6565
std::type_info *exceptionType;
66-
#ifdef __WASM_EXCEPTIONS__
66+
#ifdef __wasm__
6767
// In Wasm, a destructor returns its argument
6868
void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
6969
#else

0 commit comments

Comments
 (0)