GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-161782: Emscripten: support builds without reference types by garbear · Pull Request #161783 · python/cpython

Conversation

@garbear

@garbear garbear commented Nov 10, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

Fix Emscripten builds when WebAssembly reference types are disabled with -mno-reference-types. Fixes #161782.

CPython's optional JSPI syscall wrappers unconditionally use externref types, preventing compilation and WebAssembly instantiation on older browsers such as Chromium 85, even when JSPI is unused.

This change:

  • Guards the reference-type-dependent JSPI code with __wasm_reference_types__.
  • Provides a no-op interpreter startup hook when reference types are disabled.
  • Preserves synchronous read and poll implementations.
  • Leaves existing JSPI functionality unchanged when reference types are enabled.

The change is limited to Python/emscripten_syscalls.c and 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 externref types 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 main using Emscripten 7.0.0 and Node.js 26:

  • Both -mno-reference-types and -mreference-types compile with warnings treated as errors.
  • Eight focused runtime configurations pass, covering interpreter startup, embedded startup, synchronous syscall fallbacks, JSPI read/poll, and error handling.
  • Modules built without reference types contain no externref instructions and pass WebAssembly validation with reference types disabled.
  • The reference-types-enabled object is byte-for-byte identical to the original.
  • NEWS fragment generation and parsing pass.
  • git diff --check passes.

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

  • Issue: Emscripten build fails when WebAssembly reference types are disabled #161782

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@garbear
garbear requested a review from hoodmane as a code owner November 10, 2026 22:11
@python-cla-bot

python-cla-bot Bot commented Nov 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Nov 10, 2026
Emscripten build fails when WebAssembly reference types are disabled #161782
Open
@bedevere-app bedevere-app Bot added the awaiting review label Nov 10, 2026
@garbear
pythongh-161782: Emscripten: support builds without reference types
f0d5e4f
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 <[email protected]>
@garbear
garbear force-pushed the fix-wasm-refs branch from a9c7a9c to f0d5e4f Compare November 10, 2026 22:12
@garbear garbear mentioned this pull request Nov 10, 2026
[WASM][depends] Multiple fixes to depends for WASM xbmc/xbmc#30431
Merged
1 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hoodmane hoodmane Awaiting requested review from hoodmane hoodmane is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Emscripten build fails when WebAssembly reference types are disabled

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@garbear
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.