Skip to content

Support wasm32-unknown-emscripten#951

Draft
logan-gatlin wants to merge 9 commits intomainfrom
emscripten
Draft

Support wasm32-unknown-emscripten#951
logan-gatlin wants to merge 9 commits intomainfrom
emscripten

Conversation

@logan-gatlin
Copy link
Copy Markdown
Collaborator

@logan-gatlin logan-gatlin commented Mar 16, 2026

New emscripten build pipeline:

  • Added --emscripten CLI flag to BuildOptions.
  • New emscripten-specific post-build flow:
    1. Run emcc --post-link on the wasm-bindgen output to produce the emscripten JS runtime and post-linked wasm binary.
    2. Parse library_bindgen.js to extract exported functions and classes.
    3. Generate a thin ESM wrapper (emscripten_wrapper.js) that lazily initializes the emscripten module and exports Workers-compatible handlers + proxy classes for Durable Objects.
    4. Bundle with esbuild (wasm kept external).
    5. Clean up intermediate artifacts.
  • Added check_for_emcc() with auto-detection of EMSDK environment variable to prepend emscripten tools to PATH.

New JS template (worker-build/src/js/emscripten_wrapper.js)

Thin ESM module that imports the emscripten factory + wasm module, provides a custom instantiateWasm hook for Workers wasm loading, and exports handlers/classes via template placeholders.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 16, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 2 untouched benchmarks


Comparing emscripten (fc58343) with main (2d022ab)

Open in CodSpeed

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.

1 participant