fix(wasm): Fix asyncify rewind with asyncify-aware dynCall shims

Emscripten 4.x removed dynCall_* WASM exports, breaking asyncify
rewind through indirect calls (modal dialogs, event handlers).
Generate JS shims that track Asyncify.exportCallStack and register
in wasmExports so doRewind can find them.

Also fixes empty callback functions ((() => {})) generated by
Emscripten 4.x + pthreads for HTML5 events, pthread entry,
sighandler, async timer, and main loop callbacks.

Build pipeline improvements:
- Stub wasm-opt/finalize in Docker (RAM limits), run on host
- Add setup-emsdk.sh for reproducible Emscripten setup
- Simplify env.sh and version management

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-03-13 12:26:48 +01:00
commit b46b4b69f1
13 changed files with 150 additions and 65 deletions

60
scripts/setup-emsdk.sh Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
# Install and activate the Emscripten SDK (emsdk) locally
#
# This script is idempotent - it skips installation if the correct version
# is already installed. The emsdk is installed into tools/emsdk/ which is
# gitignored (~1.5GB).
#
# Usage:
# ./scripts/setup-emsdk.sh # Install/activate pinned version
# ./scripts/setup-emsdk.sh --force # Force reinstall
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Source version constants
source "$SCRIPT_DIR/common/versions.sh"
EMSDK_DIR="$PROJECT_ROOT/tools/emsdk"
VERSION="$EMSCRIPTEN_VERSION"
echo "=== Emscripten SDK Setup ==="
echo " Version: $VERSION"
echo " Location: $EMSDK_DIR"
# Check if already installed with correct version (unless --force)
if [ "$1" != "--force" ] && [ -f "$EMSDK_DIR/emsdk" ]; then
if "$EMSDK_DIR/emsdk" list 2>/dev/null | grep -q "^[[:space:]]*${VERSION}[[:space:]]*INSTALLED"; then
echo "Emscripten $VERSION is already installed and active."
echo "Use --force to reinstall."
exit 0
fi
fi
# Clone emsdk if not present
if [ ! -d "$EMSDK_DIR" ]; then
echo ""
echo "Cloning emsdk..."
mkdir -p "$PROJECT_ROOT/tools"
git clone https://github.com/emscripten-core/emsdk.git "$EMSDK_DIR"
else
echo ""
echo "Updating emsdk..."
(cd "$EMSDK_DIR" && git pull)
fi
# Install and activate the pinned version
echo ""
echo "Installing Emscripten $VERSION..."
"$EMSDK_DIR/emsdk" install "$VERSION"
echo ""
echo "Activating Emscripten $VERSION..."
"$EMSDK_DIR/emsdk" activate "$VERSION"
echo ""
echo "=== Setup complete ==="
echo "Emscripten $VERSION is ready."
echo "Source env.sh to use it: source scripts/common/env.sh"