You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Emscripten build fails when WebAssembly reference types are disabled #161782
CPython's Emscripten syscall overrides fail to compile when WebAssembly reference types are disabled with -mno-reference-types.
Python/emscripten_syscalls.c unconditionally uses __externref_t and reference-type builtins in its optional JavaScript Promise Integration (JSPI) read and poll wrappers. These types are unavailable when reference types are disabled, even if JSPI is never used.
Steps to reproduce
Build CPython for wasm32-emscripten using Emscripten 7.0.0.
Compile with -mno-reference-types.
Build Python/emscripten_syscalls.c.
Actual result
Compilation fails with errors involving __externref_t (nine errors in the tested configuration).
Modules containing externref also cannot instantiate in older browsers such as Chromium 85.
Expected result
CPython should compile without WebAssembly reference types, retaining synchronous read and poll syscall implementations when JSPI is unavailable.
Suggested fix
Conditionally compile the reference-type-dependent JSPI wrappers using __wasm_reference_types__, and provide a no-op interpreter startup hook when reference types are disabled.
Validation
Tested against CPython main (226813c0f7834b55be51e912a3d8555e652d9026) using Emscripten 7.0.0 and Node.js 26.
With the proposed fix:
Both reference-type configurations compile successfully.
Eight focused runtime tests pass, covering startup, synchronous syscall fallbacks, JSPI read/poll, and error handling.
The disabled configuration contains no externref instructions.
The enabled object is byte-for-byte identical to the original implementation.
A full CPython build and test suite were not run.
Originally discovered while bringing up Kodi on a Samsung Q60B running Chromium 85.
Activity
pythongh-161782: Emscripten: support builds without reference types
pythongh-161782: Emscripten: support builds without reference types