Repository navigation
Conversation
Unsupported externref types prevent older browsers from instantiating a WASM module even when JSPI is not used. Guard the JSPI syscall wrappers with __wasm_reference_types__ and make the interpreter's JSPI startup hook a no-op when reference types are disabled. Keep Emscripten's synchronous read and poll implementations and the unrelated syscall overrides available. Signed-off-by: Garrett Brown <themagnificentmrb@gmail.com>
garbear
force-pushed
the
fix-wasm-refs
branch
from
November 10, 2026 22:12
a9c7a9c to
f0d5e4f
Compare
1 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix Emscripten builds when WebAssembly reference types are disabled with
-mno-reference-types. Fixes #161782.CPython's optional JSPI syscall wrappers unconditionally use
externreftypes, preventing compilation and WebAssembly instantiation on older browsers such as Chromium 85, even when JSPI is unused.This change:
__wasm_reference_types__.The change is limited to
Python/emscripten_syscalls.cand includes a NEWS fragment.Motivation
Discovered while bringing up Kodi's WebAssembly build on a 2022 Samsung Q60B TV using Emscripten 7.0.0.
Chromium 85 does not support WebAssembly reference types. Runtime feature detection cannot prevent compilation or instantiation failures caused by unsupported
externreftypes in the module.This allows CPython to support targets without reference types while retaining JSPI functionality on newer runtimes.
Related downstream fix: xbmc/xbmc#30431
Testing
Validated against CPython
mainusing Emscripten 7.0.0 and Node.js 26:-mno-reference-typesand-mreference-typescompile with warnings treated as errors.externrefinstructions and pass WebAssembly validation with reference types disabled.git diff --checkpasses.A full CPython build and test suite were not run. The upstream change has not yet been tested directly on Samsung Chromium 85.
AI disclosure
Model: GPT-6 Astra
Thinking effort: Extra High