From cda19e0d5191bec6224634b08b384728cbfa123e Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 9 Oct 2026 11:53:28 +0200 Subject: [PATCH] :arrow_up: Use Wasm EH and SjLj for render-wasm with Rust 1.99 (#12235) Rust 1.91 links emscripten with JS exception handling, which cannot mix with SUPPORT_LONGJMP=wasm. Bump the devenv to Rust 1.99 (native Wasm EH) and align EMCC_CFLAGS / SKIA_BINARIES_URL with a Skia -ljmp-wasm prebuild so +simd128 no longer hits invoke_*V TypeErrors. --- render-wasm/_build_env | 28 ++++++++++++++++++---------- render-wasm/lint | 3 --- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/render-wasm/_build_env b/render-wasm/_build_env index 87083df47f..11c192fbb2 100644 --- a/render-wasm/_build_env +++ b/render-wasm/_build_env @@ -1,7 +1,7 @@ #!/usr/bin/env bash -export RUST_VERSION=1.91.0 +export RUST_VERSION=1.99.0 export VERSION_TAG=${VERSION:-develop}; export RENDER_TARGET="${RENDER_TARGET:-${1:-frontend}}"; @@ -22,11 +22,13 @@ fi export BUILD_NAME="${BUILD_NAME:-render-wasm}" export CARGO_BUILD_TARGET=${CARGO_BUILD_TARGET:-"wasm32-unknown-emscripten"}; export CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-"target/$RENDER_TARGET"}; -export SKIA_BINARIES_URL=${SKIA_BINARIES_URL:-"https://github.com/penpot/skia-binaries/releases/download/0.153.3/skia-binaries-b7f043e0b1e2a850e702-wasm32-unknown-emscripten-gl-svg-textlayout-binary-cache-webp-pdf-simd.tar.gz"} +# Skia prebuild with wasm SIMD and Wasm EH/SjLj (-ljmp-wasm). Must match +# EMCC_CFLAGS below. Override with SKIA_BINARIES_URL when needed. +export SKIA_BINARIES_URL=${SKIA_BINARIES_URL:-"https://github.com/penpot/skia-binaries/releases/download/0.153.3/skia-binaries-b7f043e0b1e2a850e702-wasm32-unknown-emscripten-gl-svg-textlayout-binary-cache-webp-pdf-simd-ljmp-wasm.tar.gz"} -# Let rustc emit wasm SIMD for our Rust code (autovec / core::arch::wasm32). -# Skia SIMD still comes from the -simd prebuild + -msimd128 in EMCC_CFLAGS. -# Gate on the emscripten target so native `./test` is unaffected. +# Emscripten only: rustc wasm SIMD (native `./test` unchanged). Wasm +# setjmp/longjmp comes from EMCC_CFLAGS (-sSUPPORT_LONGJMP=wasm), which emcc +# appends on compile and link. if [ "$CARGO_BUILD_TARGET" = "wasm32-unknown-emscripten" ]; then export RUSTFLAGS="${RUSTFLAGS:-} -C target-feature=+simd128" fi @@ -48,12 +50,14 @@ export EM_MEMORY_GROWTH_GEOMETRIC_STEP="0.8" # Default: dlmalloc export EM_MALLOC="dlmalloc" -# -msimd128: allow wasm SIMD in the linked module. Skia prebuilts must be -# built with the same flag (penpot/skia-binaries, WASM_SIMD=1) for Skia/skcms -# kernels to actually contain v128 ops; engines do not autovec scalar wasm. +# -msimd128: wasm SIMD in the linked module (Skia -simd prebuild must match). +# -fwasm-exceptions / SUPPORT_LONGJMP=wasm: native Wasm EH and setjmp/longjmp +# (Skia -ljmp-wasm prebuild must match). export EMCC_CFLAGS="--no-entry \ --js-library src/js/wapi.js \ -msimd128 \ + -fwasm-exceptions \ + -sSUPPORT_LONGJMP=wasm \ -sMALLOC=$EM_MALLOC \ -sINVOKE_RUN=0 \ -sALLOW_TABLE_GROWTH=0 \ @@ -66,7 +70,6 @@ export EMCC_CFLAGS="--no-entry \ -sEXPORTED_RUNTIME_METHODS=GL,UTF8ToString,stringToUTF8,HEAPU8,HEAP32,HEAPU32,HEAPF32 \ -sENVIRONMENT=web,worker,node \ -sMODULARIZE=1 \ - -sDISABLE_EXCEPTION_CATCHING=1 \ -sFILESYSTEM=0 \ -sEXPORT_ES6=1"; @@ -114,10 +117,15 @@ function clean { cargo clean; } -function setup { +function setup_rust { # Setup default rust version rustup default $RUST_VERSION rustup target add wasm32-unknown-emscripten + rustup component add clippy rustfmt --toolchain $RUST_VERSION +} + +function setup { + setup_rust pnpm install; } diff --git a/render-wasm/lint b/render-wasm/lint index aeacf782c4..097a4314cf 100755 --- a/render-wasm/lint +++ b/render-wasm/lint @@ -10,9 +10,6 @@ fi . ./_build_env frontend -export SKIA_BINARIES_URL=${SKIA_BINARIES_URL:-"https://github.com/penpot/skia-binaries/releases/download/0.153.3/skia-binaries-b7f043e0b1e2a850e702-wasm32-unknown-emscripten-gl-svg-textlayout-binary-cache-webp-pdf-simd.tar.gz"} - - ALLOWED_RULES="-D static_mut_refs" # ./lint --fix