Conversation
Instead import `setupEmscripten.ts` directly. As requested by jasnell because SetupEmscripten does not work with new module registry.
650f0e3 to
1fd9e45
Compare
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR removes the SetupEmscripten C++ code path and instead imports setupEmscripten.ts directly as an internal module, simplifying the Emscripten initialization pipeline.
- [HIGH] Debug
print()statement left inhelpers.bzl— this will produce output on every Bazel load of this file, polluting build logs. - [LOW]
python_stdlib.zip.d.tsis now a dead file — thedeclare module 'pyodide-internal:generated/python_stdlib.zip'was removed but the file remains with bare top-level declarations that nothing references. Consider deleting it entirely sincemodules.d.tsalready declares the newpyodideRuntime-internal:python_stdlib.zipmodule.
This review was generated by an AI assistant and may contain inaccuracies.
| deps = ["pyodide.asm.js@rule@" + version], | ||
| ) | ||
|
|
||
| print(_out_path("emscriptenSetup.js", version)) |
There was a problem hiding this comment.
Debug print() left in — this will produce output on every Bazel load.
| print(_out_path("emscriptenSetup.js", version)) |
| export default stdlib; | ||
| } | ||
| const stdlib: Uint8Array; | ||
| export default stdlib; |
There was a problem hiding this comment.
This file no longer declares a module (the old declare module 'pyodide-internal:generated/python_stdlib.zip' was removed). The new import path pyodideRuntime-internal:python_stdlib.zip is already typed in modules.d.ts. This file is now dead — consider deleting it.
|
Review posted on PR #6658 with two findings:
The rest of the PR looks clean: all |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Goodbye old friend - you will not be missed |
ryanking13
left a comment
There was a problem hiding this comment.
I don't have the exact context of why it was existed in C++ originally, but the change looks good overall.
| export async function getSentinelImport() { | ||
| const module: WebAssembly.Module = new WebAssembly.Module(sentinelWasm); | ||
| const instance = await WebAssembly.instantiate(module); | ||
| const { instance } = await wasmInstantiate(sentinelWasm, {}); |
There was a problem hiding this comment.
Is the second paramater of wasmInstantiate ever used?
There was a problem hiding this comment.
Well it's the imports parameter so in principle it's pretty important. This module just happens to have no imports.
There was a problem hiding this comment.
Perhaps worth at least documenting what the parameter is.
| const { instance } = await wasmInstantiate(sentinelWasm, {}); | |
| const { instance } = await wasmInstantiate(sentinelWasm, {} /* imports */); |
| import { getTrustedReadFunc } from 'pyodide-internal:readOnlyFS'; | ||
| import { PyodideVersion } from 'pyodide-internal:const'; | ||
| import { default as pythonStdlibZip } from 'pyodideRuntime-internal:python_stdlib.zip'; | ||
| import { default as pyodideAsmWasmReader } from 'pyodideRuntime-internal:pyodide.asm.wasm'; |
There was a problem hiding this comment.
nitpick: why call it a "reader"?
There was a problem hiding this comment.
Good point. Language model decision obviously.
| // Need to set these here so that the logs go to the right context. If we don't they will go | ||
| // to SetupEmscripten's context and end up being KJ_LOG'd, which we do not want. |
There was a problem hiding this comment.
Why is this comment removed?
There was a problem hiding this comment.
It's not true anymore.
There was a problem hiding this comment.
Then can we (and should we) remove this initializeStreams call?
| } | ||
|
|
||
| export function newWasmModule(buffer: Uint8Array): WebAssembly.Module { | ||
| if (!UnsafeEval) { |
There was a problem hiding this comment.
As UnsafeEval is imported directly from top-level, I guess this barrier can be removed.
dom96
left a comment
There was a problem hiding this comment.
I wonder if there are other things we can remove now that SetupEmscripten is gone.
| // Need to set these here so that the logs go to the right context. If we don't they will go | ||
| // to SetupEmscripten's context and end up being KJ_LOG'd, which we do not want. |
There was a problem hiding this comment.
Then can we (and should we) remove this initializeStreams call?
| export async function getSentinelImport() { | ||
| const module: WebAssembly.Module = new WebAssembly.Module(sentinelWasm); | ||
| const instance = await WebAssembly.instantiate(module); | ||
| const { instance } = await wasmInstantiate(sentinelWasm, {}); |
There was a problem hiding this comment.
Perhaps worth at least documenting what the parameter is.
| const { instance } = await wasmInstantiate(sentinelWasm, {}); | |
| const { instance } = await wasmInstantiate(sentinelWasm, {} /* imports */); |
Instead import
setupEmscripten.tsdirectly. As requested by @jasnell because SetupEmscripten does not work with new module registry.