WebAssembly / WebAssembly/binaryen

wasm-emscripten-finalize runs out of memory with -g option

Open
#4,261 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

I'm attempting to build a large project and debug it, but when building, the wasm-emscripten-finalize operation takes 18-20 Gigabytes of RAM to complete. In looking at the code, I would guess that this is due to the metadata being stored in a single string here:
https://github.com/WebAssembly/binaryen/blob/be02d3f0f2689475f31c4523010eed58f39d27cb/src/tools/wasm-emscripten-finalize.cpp#L302

seems like the EmscriptenGlueGenerator could be re-worked to stream that string as it's built so that it doesn't have to be saved in memory and then written out at the end.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/tools/wasm-emscripten-finalize.cpp around line 302 and inspect how EmscriptenGlueGenerator builds and writes the metadata string. Reproduce the large-project build with the -g option, then verify that finalization completes without excessive memory use and that the generated output remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.