Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions system/lib/libcxxabi/src/cxa_personality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,15 @@ __gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,
extern "C" _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code __gxx_wasm_personality_v0(void* exception_ptr) {
struct _Unwind_Exception* exception_object = (struct _Unwind_Exception*)exception_ptr;

struct _Unwind_LandingPadContext* context = _Unwind_GetWasmLPadContext();

// Reset the selector.
__wasm_lpad_context.selector = 0;
context->selector = 0;

// Call personality function. Wasm does not have two-phase unwinding, so we
// only do the search phase.
return __gxx_personality_imp(1, _UA_SEARCH_PHASE, exception_object->exception_class, exception_object,
(struct _Unwind_Context*)&__wasm_lpad_context);
return __gxx_personality_imp(
1, _UA_SEARCH_PHASE, exception_object->exception_class, exception_object, (struct _Unwind_Context*)context);
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion system/lib/libunwind/include/unwind_wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct _Unwind_LandingPadContext {

// Communication channel between compiler-generated user code and personality
// function
extern thread_local struct _Unwind_LandingPadContext __wasm_lpad_context;
#ifdef __cplusplus
extern "C"
#endif
struct _Unwind_LandingPadContext *_Unwind_GetWasmLPadContext(void);

#endif // __WASM_UNWIND_H__
7 changes: 6 additions & 1 deletion system/lib/libunwind/src/Unwind-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
#include "unwind.h"
#include <threads.h>

_LIBUNWIND_EXPORT thread_local struct _Unwind_LandingPadContext
thread_local struct _Unwind_LandingPadContext
__wasm_lpad_context;

_LIBUNWIND_EXPORT struct _Unwind_LandingPadContext *
_Unwind_GetWasmLPadContext(void) {
return &__wasm_lpad_context;
}

/// Called by __cxa_throw.
_LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_RaiseException(_Unwind_Exception *exception_object) {
Expand Down
4 changes: 2 additions & 2 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,8 @@ class libcxx(ExceptionLibrary, MTLibrary, DebugLibrary):

class libunwind(ExceptionLibrary, MTLibrary):
name = 'libunwind'
# Because calls to _Unwind_CallPersonality are generated during LTO, libunwind
# can't currently be part of LTO.
# Because calls to _Unwind_GetWasmLPadContext are generated during LTO,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by fix: _Unwind_CallPersonality was deleted from the library in #27445 but I forgot to remove this, but now we have a new function

# libunwind can't currently be part of LTO.
# See https://bugs.llvm.org/show_bug.cgi?id=44353
force_object_files = True

Expand Down
Loading