Skip to content

Commit 6a2ec34

Browse files
authored
Add a CMake flag to enable Wasm exceptions in the BinaryenJS build (#5454)
1 parent d3f2df3 commit 6a2ec34

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ option(BUILD_EMSCRIPTEN_TOOLS_ONLY "Build only tools needed by emscripten" OFF)
4646
# Turn this on to build binaryen.js as ES5, with additional compatibility configuration for js_of_ocaml.
4747
option(JS_OF_OCAML "Build binaryen.js for js_of_ocaml" OFF)
4848

49+
# Turn this on to use the Wasm EH feature instead of emscripten EH in the wasm/BinaryenJS builds
50+
option(EMSCRIPTEN_ENABLE_WASM_EH "Enable Wasm EH feature in emscripten build" OFF)
51+
4952
# For git users, attempt to generate a more useful version string
5053
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
5154
find_package(Git QUIET REQUIRED)
@@ -313,8 +316,12 @@ if(EMSCRIPTEN)
313316
endif()
314317

315318
add_link_flag("-sALLOW_MEMORY_GROWTH")
316-
add_compile_flag("-sDISABLE_EXCEPTION_CATCHING=0")
317-
add_link_flag("-sDISABLE_EXCEPTION_CATCHING=0")
319+
if(EMSCRIPTEN_ENABLE_WASM_EH)
320+
add_compile_flag("-fwasm-exceptions")
321+
else()
322+
add_compile_flag("-sDISABLE_EXCEPTION_CATCHING=0")
323+
add_link_flag("-sDISABLE_EXCEPTION_CATCHING=0")
324+
endif()
318325
# make the tools immediately usable on Node.js
319326
add_link_flag("-sNODERAWFS")
320327
# in opt builds, LTO helps so much (>20%) it's worth slow compile times

scripts/test/binaryenjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test(cmd):
6060
test([shared.MOZJS, '-m', 'a.mjs'])
6161
if shared.NODEJS:
6262
if node_has_wasm or 'WebAssembly.' not in test_src:
63-
test([shared.NODEJS, 'a.mjs'])
63+
test([shared.NODEJS, '--experimental-wasm-eh', 'a.mjs'])
6464
else:
6565
print('Skipping ' + test_path + ' because WebAssembly might not be supported')
6666

0 commit comments

Comments
 (0)