aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libunwind/patches/04-wasm-exceptions.patch
blob: 969f8c328353511f59f75d6dd27693b672e0ee90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--- contrib/libs/libunwind/src/Unwind-wasm.c
+++ contrib/libs/libunwind/src/Unwind-wasm.c
@@ -14,9 +14,10 @@

 #include "config.h"

-#ifdef __WASM_EXCEPTIONS__

 #include "unwind.h"
+
+#ifdef __WASM_EXCEPTIONS__
 #include <threads.h>

 _Unwind_Reason_Code __gxx_personality_wasm0(int version, _Unwind_Action actions,
@@ -120,4 +121,18 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context __attribute__((unused)))
   return 0;
 }

+#elif defined(__EMSCRIPTEN__)
+/// Called by __cxa_throw.
+/// Define it here to prevent linker errors if we're buildingig Wasm modules
+/// without exception support.
+_LIBUNWIND_EXPORT _Unwind_Reason_Code
+_Unwind_RaiseException(_Unwind_Exception *exception_object __attribute__((unused))) {
+  abort();
+}
+
+#if !defined(NDEBUG) && defined(STANDALONE_WASM)
+void __throw_exception_with_stack_trace(_Unwind_Exception* ex) {
+  _Unwind_RaiseException(ex);
+}
+#endif
 #endif // defined(__WASM_EXCEPTIONS__)