Skip to content

Bugfix for WASM Build with emscripten >6.0.2#536

Open
Intubun wants to merge 2 commits into
RTimothyEdwards:masterfrom
Intubun:master
Open

Bugfix for WASM Build with emscripten >6.0.2#536
Intubun wants to merge 2 commits into
RTimothyEdwards:masterfrom
Intubun:master

Conversation

@Intubun

@Intubun Intubun commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR is related to Issue #533 . Here a small summary:

  • What broke it — emscripten 6.0.2 (6.0.1 was fine) made two sysroot/default changes: it started shipping a
    <sys/epoll.h> stub, and it dropped wasmBinary from the default INCOMING_MODULE_JS_API list. Both broke the
    WASM build in different ways.
    • toolchains/emscripten/build-tcl-wasm.sh — Added ac_cv_header_sys_epoll_h=no to TCL's configure
      invocation, forcing the select()-based notifier. The new <sys/epoll.h> stub made TCL pick the epoll
      notifier (tclEpollNotfy.c), which needs <sys/queue.h> — a header emscripten doesn't provide — causing a
      compile-time fatal error: 'sys/queue.h' file not found.
    • toolchains/emscripten/defs.mak — Added -sINCOMING_MODULE_JS_API= (emscripten's full default list plus
      wasmBinary). Because wasmBinary was removed from the default, the loaders passing Module.wasmBinary
      triggered a hard runtime abort under -sASSERTIONS=1 (Module.wasmBinary … not included in
      INCOMING_MODULE_JS_API), failing every example test.

Intubun added 2 commits July 7, 2026 14:14
…en 6.0.2. The failure is not in magic itself but in the TCL dependency build: emscripten 6.0.2 began shipping a <sys/epoll.h> stub in its sysroot (6.0.1 did not), so TCL's configure now detects epoll on the Linux CI host via AC_CHECK_HEADERS([sys/epoll.h]), defines NOTIFIER_EPOLL, and compiles tclEpollNotfy.c. That file also requires <sys/queue.h>, which emscripten does not provide, so the build died with "fatal error: 'sys/queue.h' file not found". Fixed by passing ac_cv_header_sys_epoll_h=no to TCL's configure in toolchains/emscripten/build-tcl-wasm.sh, which forces the select()-based notifier. That notifier is the correct choice for single-threaded WASM anyway (emscripten's epoll is only a stub), and overriding the autoconf cache variable avoids patching the read-only TCL source tree and keeps the build working across future emscripten versions.
…e 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant