From 752d80ba0198262bf99d620a40e016d34e9fda8c Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Thu, 23 Jul 2026 12:51:20 +0000 Subject: [PATCH] wasm: pin INCOMING_MODULE_JS_API (fixes wasmBinary abort on emsdk 6.x) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Emscripten's default INCOMING_MODULE_JS_API list dropped `wasmBinary` (present through ~4.x, gone by 6.0.x). With -sASSERTIONS=1 a caller that sets Module.wasmBinary — as the npm harness and the documented API do — then aborts at instantiation: Aborted(`Module.wasmBinary` was supplied but `wasmBinary` not included in INCOMING_MODULE_JS_API) Set the list explicitly so the build no longer depends on Emscripten's default (which drifts between emsdk versions). Allow the properties that matter for embedding/consuming the .wasm across node/web/worker: print, printErr stdout/stderr callbacks wasmBinary, wasm supply the module as bytes / a compiled Module instantiateWasm, locateFile custom instantiation (streaming/caching/ bundlers) and .wasm URL resolution `arguments` is intentionally omitted: main() is defined but never run (magic is driven through the magic_wasm_* exports), so argv is inert here. Verified on emsdk 6.0.2 and 6.0.3: the wasmBinary abort is gone and the module instantiates (0 INCOMING aborts in the smoke run on either). Co-Authored-By: Claude Opus 4.8 (1M context) --- toolchains/emscripten/defs.mak | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/toolchains/emscripten/defs.mak b/toolchains/emscripten/defs.mak index 2f612c72..daed4da7 100644 --- a/toolchains/emscripten/defs.mak +++ b/toolchains/emscripten/defs.mak @@ -26,11 +26,6 @@ MAKE_WASM = 1 LINK = $(LD) -r $(LDFLAGS) # Emscripten linker flags. -# The link step runs from the magic/ build subdirectory. Embed-file inputs -# must name the *right tree*: generated data (the scmos tech files, produced by -# `make techs`) lives in the build tree, so use ${MAGICDIR} (the build top); -# verbatim data (the window glyphs, shipped as source) lives in the source tree, -# so use ${MAGICSRC}. In-tree the two coincide. # # INCOMING_MODULE_JS_API is emscripten's default list plus `wasmBinary`. # Our JS loaders (npm/examples/*.js) pass Module.wasmBinary to embed the .wasm, @@ -40,6 +35,12 @@ LINK = $(LD) -r $(LDFLAGS) # in INCOMING_MODULE_JS_API". We spell out the full default list (so external # consumers passing locateFile/arguments/etc. keep working) and re-add # wasmBinary. Keep this in sync with emscripten's default if it grows. +# +# The link step runs from the magic/ build subdirectory. Embed-file inputs +# must name the *right tree*: generated data (the scmos tech files, produced by +# `make techs`) lives in the build tree, so use ${MAGICDIR} (the build top); +# verbatim data (the window glyphs, shipped as source) lives in the source tree, +# so use ${MAGICSRC}. In-tree the two coincide. TOP_EXTRA_LIBS += \ ${TOP_FIRST_LIBS_WASM} \ -sWASM=1 \