From a62778efa4f921a19532c208f34a381be36b0189 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 21 May 2024 22:19:14 +0000 Subject: [PATCH] [EH] Guard destructor changes in libc++abi with __wasm__ 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. --- system/lib/libcxxabi/include/cxxabi.h | 2 +- system/lib/libcxxabi/src/cxa_exception.cpp | 4 ++-- system/lib/libcxxabi/src/cxa_exception.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/lib/libcxxabi/include/cxxabi.h b/system/lib/libcxxabi/include/cxxabi.h index d709072ca79f5..0e3969084e04f 100644 --- a/system/lib/libcxxabi/include/cxxabi.h +++ b/system/lib/libcxxabi/include/cxxabi.h @@ -58,7 +58,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB // 2.4.3 Throwing the Exception Object extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception, std::type_info *tinfo, -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm__ void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); #else void (_LIBCXXABI_DTOR_FUNC *dest)(void *)); diff --git a/system/lib/libcxxabi/src/cxa_exception.cpp b/system/lib/libcxxabi/src/cxa_exception.cpp index a0b67e0ed68ab..e06756184aa79 100644 --- a/system/lib/libcxxabi/src/cxa_exception.cpp +++ b/system/lib/libcxxabi/src/cxa_exception.cpp @@ -207,7 +207,7 @@ void __cxa_free_exception(void *thrown_object) throw() { } __cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo, -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() { #else @@ -279,7 +279,7 @@ void __throw_exception_with_stack_trace(_Unwind_Exception*); #endif void -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm__ // In Wasm, a destructor returns its argument __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { #else diff --git a/system/lib/libcxxabi/src/cxa_exception.h b/system/lib/libcxxabi/src/cxa_exception.h index 60f3aeef25df1..37ee7bc0345f7 100644 --- a/system/lib/libcxxabi/src/cxa_exception.h +++ b/system/lib/libcxxabi/src/cxa_exception.h @@ -63,7 +63,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // Manage the exception object itself. std::type_info *exceptionType; -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else