Skip to content

Remove SetupEmscripten C++ code#6658

Open
hoodmane wants to merge 1 commit intomainfrom
hoodmane/remove-emscripten-setup
Open

Remove SetupEmscripten C++ code#6658
hoodmane wants to merge 1 commit intomainfrom
hoodmane/remove-emscripten-setup

Conversation

@hoodmane
Copy link
Copy Markdown
Contributor

Instead import setupEmscripten.ts directly. As requested by @jasnell because SetupEmscripten does not work with new module registry.

@hoodmane hoodmane requested review from a team as code owners April 24, 2026 00:42
Instead import `setupEmscripten.ts` directly. As requested by jasnell because
SetupEmscripten does not work with new module registry.
@hoodmane hoodmane force-pushed the hoodmane/remove-emscripten-setup branch from 650f0e3 to 1fd9e45 Compare April 24, 2026 00:43
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

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.

  1. [HIGH] Debug print() statement left in helpers.bzl — this will produce output on every Bazel load of this file, polluting build logs.
  2. [LOW] python_stdlib.zip.d.ts is now a dead file — the declare 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 since modules.d.ts already declares the new pyodideRuntime-internal:python_stdlib.zip module.

This review was generated by an AI assistant and may contain inaccuracies.

Comment thread src/pyodide/helpers.bzl
deps = ["pyodide.asm.js@rule@" + version],
)

print(_out_path("emscriptenSetup.js", version))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Debug print() left in — this will produce output on every Bazel load.

Suggested change
print(_out_path("emscriptenSetup.js", version))

export default stdlib;
}
const stdlib: Uint8Array;
export default stdlib;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 24, 2026

Review posted on PR #6658 with two findings:

  1. [HIGH] Debug print() left in src/pyodide/helpers.bzl:284 — this will produce output on every Bazel load, polluting build logs. Posted a suggestion to remove it.

  2. [LOW] src/pyodide/types/python_stdlib.zip.d.ts is now a dead file — the module declaration was removed but the file remains with bare top-level declarations that nothing references. Suggested deleting it since modules.d.ts already declares the new pyodideRuntime-internal:python_stdlib.zip module.

The rest of the PR looks clean: all SetupEmscripten/EmscriptenRuntime references are fully removed, the C++ deletion is complete, the Bazel module type reclassifications (data -> internal/wasm) are correct, and the TypeScript signature change from sync to async loadPyodide is properly awaited at the call site.

github run

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 24, 2026

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing hoodmane/remove-emscripten-setup (1fd9e45) with main (73c75fa)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@danlapid
Copy link
Copy Markdown
Collaborator

Goodbye old friend - you will not be missed

Copy link
Copy Markdown
Contributor

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

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, {});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the second paramater of wasmInstantiate ever used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well it's the imports parameter so in principle it's pretty important. This module just happens to have no imports.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps worth at least documenting what the parameter is.

Suggested change
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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: why call it a "reader"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Language model decision obviously.

Comment on lines -294 to -295
// 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this comment removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not true anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then can we (and should we) remove this initializeStreams call?

}

export function newWasmModule(buffer: Uint8Array): WebAssembly.Module {
if (!UnsafeEval) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As UnsafeEval is imported directly from top-level, I guess this barrier can be removed.

Copy link
Copy Markdown
Contributor

@dom96 dom96 left a comment

Choose a reason for hiding this comment

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

I wonder if there are other things we can remove now that SetupEmscripten is gone.

Comment on lines -294 to -295
// 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, {});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps worth at least documenting what the parameter is.

Suggested change
const { instance } = await wasmInstantiate(sentinelWasm, {});
const { instance } = await wasmInstantiate(sentinelWasm, {} /* imports */);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants