Skip to content

gh-145037: Fix Emscripten trampoline with emcc >= 4.0.19#145038

Merged
freakboy3742 merged 2 commits intopython:mainfrom
hoodmane:emscripten-trampoline-pointer
Feb 25, 2026
Merged

gh-145037: Fix Emscripten trampoline with emcc >= 4.0.19#145038
freakboy3742 merged 2 commits intopython:mainfrom
hoodmane:emscripten-trampoline-pointer

Conversation

@hoodmane
Copy link
Contributor

@hoodmane hoodmane commented Feb 20, 2026

This undoes a change made as a part of #137470. We add an emscripten_trampoline field in pycore_runtime_structs.h and initialize it from JS initialization code with the wasm-gc based trampoline if possible. Otherwise we fall back to the JS trampoline.

cc @freakboy3742 @ryanking13

This undoes a change made as a part of PR 137470. We add an `emscripten_trampoline`
field in `pycore_runtime_structs.h` and initialize it from JS initialization code with
the wasm-gc based trampoline if possible. Otherwise we fall back to the JS trampoline.
@hoodmane hoodmane force-pushed the emscripten-trampoline-pointer branch from 200d8fe to 526e102 Compare February 20, 2026 15:39
@hoodmane hoodmane added OS-emscripten interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Feb 20, 2026
@freakboy3742
Copy link
Contributor

!buildbot emscripten

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 526e102 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F145038%2Fmerge

The command will test the builders whose names match following regular expression: emscripten

The builders matched are:

  • WASM Emscripten PR

@freakboy3742
Copy link
Contributor

@hoodmane Not sure what is going on here, but this has broken the Emscripten buildbot.

@hoodmane
Copy link
Contributor Author

Looks like there are some mistakes to fix here.

@hoodmane
Copy link
Contributor Author

!buildbot emscripten

I think it should be better now.

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @hoodmane for commit f3d03d3 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F145038%2Fmerge

The command will test the builders whose names match following regular expression: emscripten

The builders matched are:

  • WASM Emscripten PR

@hoodmane
Copy link
Contributor Author

Okay now it is better.

Copy link
Contributor

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense; one detail flagged inline that I want to confirm before approving.

PyObject* self,
PyObject* args,
PyObject* kw);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only part that gives me pause - I'm not sure if the specific offsets inside this structure are something that have consequences. There's no explicit CODEOWNERS reference for this file; @ericsnowcurrently has a few close-by entries, and @markshannon has most of the git blames

For the two of you - are there any offset/ordering concerns in pyruntimestate (even if just from a code organization perspective) that we should be concern about here?

Or if CODEOWNERS/git blame has mislead me... any idea who I should be asking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting I should add this at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, #137470 changed this header without problem, so if there is someone relying on offsets in this struct they started doing so after then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the end is a better place - I was mostly checking with Eric/Mark to see if there were any conventions I wasn't (but should be) aware of. But given the history from #137470, maybe I'm overthinking it.

@freakboy3742 freakboy3742 merged commit 43fdb70 into python:main Feb 25, 2026
49 checks passed
@hoodmane
Copy link
Contributor Author

Thanks for the review @freakboy3742 !

@hoodmane hoodmane deleted the emscripten-trampoline-pointer branch February 26, 2026 07:35
@hoodmane
Copy link
Contributor Author

Can we backport to 3.14.x?

@freakboy3742 freakboy3742 added the needs backport to 3.14 bugs and security fixes label Feb 26, 2026
@miss-islington-app
Copy link

Thanks @hoodmane for the PR, and @freakboy3742 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 26, 2026
…nGH-145038)

This undoes a change made as a part of PR 137470, for compatibility with EMSDK
4.0.19. It adds `emscripten_trampoline` field in `pycore_runtime_structs.h`
and initializes it from JS initialization code with the wasm-gc based trampoline
if possible. Otherwise we fall back to the JS trampoline.
(cherry picked from commit 43fdb70)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 26, 2026

GH-145283 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Feb 26, 2026
@freakboy3742
Copy link
Contributor

I wasn't sure if a backport was needed, since 3.14 is theoretically locked at 4.0.9; but I guess it doesn't hurt to allow for forwards compatibility.

freakboy3742 pushed a commit that referenced this pull request Feb 27, 2026
…45038) (#145283)

This undoes a change made as a part of PR 137470, for compatibility with EMSDK
4.0.19. It adds `emscripten_trampoline` field in `pycore_runtime_structs.h`
and initializes it from JS initialization code with the wasm-gc based trampoline
if possible. Otherwise we fall back to the JS trampoline.
(cherry picked from commit 43fdb70)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
bkap123 pushed a commit to bkap123/cpython that referenced this pull request Feb 28, 2026
…n#145038)

This undoes a change made as a part of PR 137470, for compatibility with EMSDK
4.0.19. It adds `emscripten_trampoline` field in `pycore_runtime_structs.h`
and initializes it from JS initialization code with the wasm-gc based trampoline
if possible. Otherwise we fall back to the JS trampoline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-emscripten skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants