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
7 changes: 0 additions & 7 deletions src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2239,13 +2239,6 @@ addToLibrary({
__stack_high: '{{{ STACK_HIGH }}}',
__stack_low: '{{{ STACK_LOW }}}',
__global_base: '{{{ GLOBAL_BASE }}}',
#if WASM_EXCEPTIONS
// In dynamic linking we define tags here and feed them to each module
__cpp_exception: "new WebAssembly.Tag({'parameters': ['{{{ POINTER_WASM_TYPE }}}']})",
#endif
#if SUPPORT_LONGJMP == 'wasm'
__c_longjmp: "new WebAssembly.Tag({'parameters': ['{{{ POINTER_WASM_TYPE }}}']})",
#endif
#if ASYNCIFY == 1
__asyncify_state: "new WebAssembly.Global({'value': 'i32', 'mutable': true}, 0)",
__asyncify_data: "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}, {{{ to64(0) }}})",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ var LibraryDylink = {
continue;
}
#endif
if (typeof value == 'object') {
if (typeof value?.value != 'undefined') {
// a breaking change in the wasm spec, globals are now objects
// https://github.com/WebAssembly/mutable-global/issues/1
value = value.value;
Expand Down
23 changes: 23 additions & 0 deletions system/lib/compiler-rt/__c_longjmp.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2025 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*
* Define the `__c_longjmp` Wasm EH tag which is used to implment setjmp/longjmp
* in LLVM.
*/

#ifdef __wasm_exception_handling__

#ifdef __wasm64__
#define PTR i64
#else
#define PTR i32
#endif

.globl __c_longjmp
.tagtype __c_longjmp PTR
__c_longjmp:

#endif // !__wasm_exception_handling__
23 changes: 23 additions & 0 deletions system/lib/libcxxabi/src/__cpp_exception.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2025 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*
* Define the `__cpp_exception` Wasm EH tag which is used to implmenent C++
* exception handling in LLVM.
*/

#ifdef __wasm_exception_handling__

#ifdef __wasm64__
#define PTR i64
#else
#define PTR i32
#endif

.globl __cpp_exception
.tagtype __cpp_exception PTR
__cpp_exception:

#endif // !__wasm_exception_handling__
8 changes: 4 additions & 4 deletions test/code_size/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 26969,
"a.out.js.gz": 11479,
"a.out.js": 26979,
"a.out.js.gz": 11483,
"a.out.nodebug.wasm": 18567,
"a.out.nodebug.wasm.gz": 9199,
"total": 45536,
"total_gz": 20678,
"total": 45546,
"total_gz": 20682,
"sent": [
"__heap_base",
"__indirect_function_table",
Expand Down
4 changes: 2 additions & 2 deletions test/code_size/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 246021,
"a.out.js": 246031,
"a.out.nodebug.wasm": 597767,
"total": 843788,
"total": 843798,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
2 changes: 2 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4951,9 +4951,11 @@ def test_dylink_exceptions_try_catch_2(self):
@no_js_math('JS_MATH is not compatible with MAIN_MODULE')
def test_dylink_exceptions_try_catch_6(self):
create_file('main.cpp', r'''
#include <assert.h>
#include <dlfcn.h>
int main() {
void* handle = dlopen("liblib.so", RTLD_LAZY);
assert(handle);
void (*side)(void) = (void (*)(void))dlsym(handle, "side");
(side)();
return 0;
Expand Down
2 changes: 2 additions & 0 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ class libcompiler_rt(MTLibrary, SjLjLibrary):
'emscripten_setjmp.c',
'emscripten_exception_builtins.c',
'emscripten_tempret.s',
'__c_longjmp.S',
'__trap.c',
])

Expand Down Expand Up @@ -1661,6 +1662,7 @@ def get_files(self):
'stdlib_typeinfo.cpp',
'private_typeinfo.cpp',
'cxa_exception_js_utils.cpp',
'__cpp_exception.S',
]
if self.eh_mode == Exceptions.NONE:
filenames += ['cxa_noexception.cpp']
Expand Down