Skip to content

Commit b86318a

Browse files
leftibotclaude
andauthored
Fix #155: fix wasm builds (#156)
* Fix #155: switch WASM builds from legacy Asyncify to JSPI cmake/Emscripten.cmake set both -fwasm-exceptions (compile + link) and -sASYNCIFY=1 (per-target link), and recent emsdk releases hard-fail the combination in wasm-opt with `__asyncify_get_call_index does not exist`, breaking the wasm.yml workflow. JSPI (JavaScript Promise Integration) is the upstream-recommended replacement for legacy Asyncify and is compatible with native WebAssembly exception handling, so the per-target flag now reads -sJSPI=1 and the no-longer-relevant myproject_WASM_ASYNCIFY_STACK_SIZE cache variable is dropped. A new CMake-script regression test stubs the target/global option commands, includes Emscripten.cmake under EMSCRIPTEN=TRUE, and asserts that the legacy flags are gone, JSPI is emitted, and -fwasm-exceptions remains. * Address review: remove WASM cmake-script regression test Requested by @lefticus in PR #156 review. * Address review: switch WASM EH to -fexceptions, restore Asyncify Native wasm exceptions (-fwasm-exceptions) are incompatible with legacy Asyncify, and JSPI is not yet available in all browsers. Switch the Emscripten exception model to -fexceptions (JS-based) and restore -sASYNCIFY=1 / -sASYNCIFY_STACK_SIZE so the WASM build keeps working across every browser that supports threads, until JSPI is universally available. Requested by @lefticus in PR #156 review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: leftibot <leftibot@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a3971f5 commit b86318a

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

cmake/Emscripten.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ if(EMSCRIPTEN)
4545
set(myproject_WASM_ASYNCIFY_STACK_SIZE "65536" CACHE STRING
4646
"Asyncify stack size in bytes (default: 64KB)")
4747

48-
# For Emscripten WASM builds, FTXUI requires pthreads and native exception handling
49-
# Set these flags early so they propagate to all dependencies
50-
add_compile_options(-pthread -fwasm-exceptions)
51-
add_link_options(-pthread -fwasm-exceptions)
48+
# For Emscripten WASM builds, FTXUI requires pthreads and exception handling.
49+
# We use -fexceptions (JS-based exceptions) rather than -fwasm-exceptions
50+
# because native wasm exceptions are incompatible with legacy Asyncify, and
51+
# JSPI (the modern Asyncify replacement) is not yet shipping in all browsers.
52+
# Set these flags early so they propagate to all dependencies.
53+
add_compile_options(-pthread -fexceptions)
54+
add_link_options(-pthread -fexceptions)
5255
endif()
5356

5457
# Function to apply WASM settings to a target
@@ -89,7 +92,9 @@ function(myproject_configure_wasm_target target)
8992
"-sUSE_PTHREADS=1"
9093
"-sPROXY_TO_PTHREAD=1"
9194
"-sPTHREAD_POOL_SIZE=${myproject_WASM_PTHREAD_POOL_SIZE}"
92-
# Enable asyncify for emscripten_sleep and async operations
95+
# Enable Asyncify for emscripten_sleep and other async operations.
96+
# Paired with -fexceptions (JS-based exception handling) above, since
97+
# Asyncify is not compatible with native wasm exceptions.
9398
"-sASYNCIFY=1"
9499
"-sASYNCIFY_STACK_SIZE=${myproject_WASM_ASYNCIFY_STACK_SIZE}"
95100
# Memory configuration

0 commit comments

Comments
 (0)