Replace the legacy Emscripten JS-exceptions model with native wasm-EH (legacy encoding) across the whole build, keeping Asyncify coroutines working via a from-source Binaryen --hoist-cpp-catches pre-pass. Net result: native-EH is the only build mode, the 3D viewer is on by default, and pcbnew shrinks substantially. Highlights: - Binaryen submodule everywhere + --hoist-cpp-catches integration in apply-asyncify; post-link Asyncify covers every app wasm (not just standalone test wasm). - Build deps (incl. OpenCASCADE without OCC_CONVERT_SIGNALS) and all KiCad apps with -fwasm-exceptions; emscripten_sleep added to the post-link asyncify-imports. - libcontext fiber entry wired under native exceptions; while-loop main loop + currData shim injected into all wx apps. - Native-EH collab apply fixed: DEBUG-define the embind TU + match all out-of-CMake C++ TUs' ABI flags to the core, fixing the vtable-layout skew / mis-dispatch. - 3D viewer enabled by default (real raytracer linked, not the stub). - Retire the EH-spike scaffolding; flip the asyncify-races ablation pins to shim-redundancy pins (native-EH stays clean with the legacy shims ablated). - Fix the asyncify-races quiescence check to not require Asyncify.currData==0: under the native-EH per-frame-yield top loop the main stack is asyncify-suspended every frame, so currData legitimately churns (a freed-but-not-yet-nulled buffer, not a leak). Refresh the pcbnew toolbar screenshot baseline for the new kicad. - CI: drop the obsolete binaryen_version input/env (the build uses the binaryen submodule fork's wasm-opt, not a version download); key the wasm-output cache on the binaryen submodule SHA instead. Bumps the wxwidgets + binaryen submodules to their squashed feature commits. Validated green: all 7 apps native-EH (real 3D in pcbnew); KiCad e2e 63/63 Firefox + Chromium (3D viewer renders); wx 336; coroutine 34/34 both engines; asyncify 7/7 both engines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
3.8 KiB
Shell
Executable file
57 lines
3.8 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Regression test for the value-typed (concrete-result) path of --hoist-cpp-catches.
|
|
#
|
|
# Value-typed cpp-catch tries do not arise from normal C++ EH lowering (LLVM keeps catch values in
|
|
# locals → void/unreachable tries), so this case can't live in a C++ EH toy. These
|
|
# hand-written modules exercise it directly:
|
|
# (1) fuzz-exec — the pass must preserve the result value of value-typed cpp-catch tries
|
|
# (exception path, no-exception path, and exception-payload routing).
|
|
# (2) a real asyncify unwind/rewind through a value-typed catch that SUSPENDS (must yield 50).
|
|
#
|
|
# Requires wasm-opt built from the binaryen submodule (scripts/binaryen-hoist-pass/build-wasm-opt.sh);
|
|
# that one binary (version_130 + our hoist pass) does both --hoist-cpp-catches and --asyncify. Run from anywhere.
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
|
|
DIR="$ROOT/scripts/binaryen-hoist-pass/tests"
|
|
WASMOPT="$ROOT/build-wasm/tools/binaryen-hoist-build/bin/wasm-opt"
|
|
V130="$WASMOPT" # the submodule fork IS version_130 (asyncify unchanged), so it does --asyncify too
|
|
[ -x "$WASMOPT" ] || { echo "build wasm-opt first: scripts/binaryen-hoist-pass/build-wasm-opt.sh"; exit 1; }
|
|
|
|
echo "== (1) value semantics preserved (fuzz-exec) =="
|
|
"$WASMOPT" --hoist-cpp-catches -all -all --fuzz-exec "$DIR/value-typed-cpp-catch.wat" -o /dev/null 2>&1 \
|
|
| grep -E 'comparing|=>'
|
|
|
|
echo "== (2) asyncify unwind/rewind through a value-typed suspending catch =="
|
|
"$WASMOPT" --hoist-cpp-catches -all -all "$DIR/value-typed-suspend.wat" -o /tmp/vt_s.hoisted.wasm
|
|
"$V130" --asyncify -all --pass-arg=asyncify-imports@env.sleep /tmp/vt_s.hoisted.wasm -o /tmp/vt_s.async.wasm
|
|
node "$DIR/asyncify-harness.js" /tmp/vt_s.async.wasm
|
|
echo "OK — value-typed path verified"
|
|
|
|
# Regression for the PGM_BASE::HandleException shape: a cpp catch nested in an outer try's catch_all
|
|
# cleanup pad whose arm br's to an intervening block ($blk). Before the fix the hoisted arm's br was
|
|
# orphaned -> "all break targets must be valid". (3) validates + checks value semantics; (4) drives a
|
|
# real unwind/rewind through the hoisted arm with the retargeted br.
|
|
echo "== (3) nested-catchall exit-block hoists + validates (fuzz-exec: caught=>42, normal=>7) =="
|
|
"$WASMOPT" --hoist-cpp-catches -all -all --fuzz-exec "$DIR/nested-catchall-exit-block.wat" -o /dev/null 2>&1 \
|
|
| grep -E 'comparing|=>'
|
|
|
|
echo "== (4) asyncify unwind/rewind through a suspending nested-catchall arm =="
|
|
"$WASMOPT" --hoist-cpp-catches -all -all "$DIR/nested-catchall-suspend.wat" -o /tmp/ncb_s.hoisted.wasm
|
|
"$V130" --asyncify -all --pass-arg=asyncify-imports@env.sleep /tmp/ncb_s.hoisted.wasm -o /tmp/ncb_s.async.wasm
|
|
node "$DIR/asyncify-harness.js" /tmp/ncb_s.async.wasm
|
|
echo "OK — nested-catchall path verified"
|
|
|
|
# Regression for the SYMBOL_EDIT_FRAME::DuplicateSymbol shape: a cpp catch arm hoisted PAST an ancestor
|
|
# catch_all carries a nested __cxa_end_catch cleanup (try (do ..) (delegate $M)) whose delegate target
|
|
# sits inside that catch_all -> orphaned by hoisting ("all delegate targets must be valid"). The fix
|
|
# retargets it to DELEGATE_CALLER_TARGET. (5) validates + checks value semantics; (6) drives a real
|
|
# unwind/rewind through the hoisted arm with the retargeted delegate.
|
|
echo "== (5) delegate-orphan hoists + validates (fuzz-exec: caught=>42, normal=>7) =="
|
|
"$WASMOPT" --hoist-cpp-catches -all -all --fuzz-exec "$DIR/delegate-orphan.wat" -o /dev/null 2>&1 \
|
|
| grep -E 'comparing|=>'
|
|
|
|
echo "== (6) asyncify unwind/rewind through a suspending delegate-orphan arm =="
|
|
"$WASMOPT" --hoist-cpp-catches -all -all "$DIR/delegate-orphan-suspend.wat" -o /tmp/dlg_s.hoisted.wasm
|
|
"$V130" --asyncify -all --pass-arg=asyncify-imports@env.sleep /tmp/dlg_s.hoisted.wasm -o /tmp/dlg_s.async.wasm
|
|
node "$DIR/asyncify-harness.js" /tmp/dlg_s.async.wasm
|
|
echo "OK — delegate-orphan path verified"
|