Fixed a second emscripten 6.0.2 regression in the WASM build, this one at runtime rather than at compile time. emscripten 6.0.2 removed wasmBinary (along with a batch of GL/SDL members) from the default INCOMING_MODULE_JS_API list. The JS loaders in npm/examples pass Module.wasmBinary to embed the .wasm binary, and because the WASM build links with -sASSERTIONS=1, the now-unrecognized member triggers a hard runtime abort: "`Module.wasmBinary` was supplied but `wasmBinary` not included in INCOMING_MODULE_JS_API", failing every example test. Fixed by explicitly setting -sINCOMING_MODULE_JS_API in toolchains/emscripten/defs.mak to emscripten's full default list plus wasmBinary. Spelling out the whole default (rather than only the members our own loaders use) keeps external consumers of the npm package working if they supply locateFile, arguments, and similar Module options.

This commit is contained in:
Intubun 2026-07-07 14:14:21 +02:00 committed by R. Timothy Edwards
parent 28483435f1
commit d6438387ad
1 changed files with 10 additions and 0 deletions

View File

@ -20,6 +20,15 @@ MAKE_WASM = 1
# Emscripten linker flags.
# The link step runs from the magic/ subdirectory, so embed-file paths
# are relative to that directory (../scmos, ../windows/...).
#
# INCOMING_MODULE_JS_API is emscripten's default list plus `wasmBinary`.
# Our JS loaders (npm/examples/*.js) pass Module.wasmBinary to embed the .wasm,
# but emscripten 6.0.2 dropped wasmBinary (and a batch of GL/SDL members) from
# the default INCOMING_MODULE_JS_API. With ASSERTIONS=1 that turns into a hard
# runtime abort: "`Module.wasmBinary` was supplied but `wasmBinary` not included
# 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.
TOP_EXTRA_LIBS += \
-sWASM=1 \
-sMODULARIZE=1 \
@ -27,6 +36,7 @@ TOP_EXTRA_LIBS += \
-sUSE_ZLIB=1 \
-sEXPORTED_FUNCTIONS=_magic_wasm_init,_magic_wasm_run_command,_magic_wasm_source_file,_magic_wasm_update \
-sEXPORTED_RUNTIME_METHODS=cwrap,ccall,FS,setValue,getValue \
-sINCOMING_MODULE_JS_API=ENVIRONMENT,arguments,canvas,dynamicLibraries,elementPointerLock,instantiateWasm,locateFile,monitorRunDependencies,noExitRuntime,noInitialRun,onAbort,onExit,onRuntimeInitialized,postRun,preInit,preRun,print,printErr,setStatus,statusMessage,stderr,stdin,stdout,thisProgram,wasm,websocket,wasmBinary \
-sALLOW_MEMORY_GROWTH=1 \
-sINITIAL_MEMORY=67108864 \
-Wl,-z,stack-size=10485760 \