binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

wasm-emscripten-finalize doesn't preserve sourcesContent

Open verhovsky opened this issue 1 year ago • 0 comments

If you can't host the files for your source map, you can put their contents in the sourcesContent field of your source map JSON file https://tc39.es/source-map/#sourcescontent

When emscripten runs wasm-emscripten-finalize on a source map file that has that field set

https://github.com/emscripten-core/emscripten/blob/cf0ec7a4426203d76f958216d14ad9f4513d8481/tools/emscripten.py#L488-L491

wasm-emscripten-finalize removes it.

https://github.com/emscripten-core/emscripten/pull/22190

verhovsky avatar Aug 02 '24 06:08 verhovsky

Thanks @mkl-ableton for pinging on this. This applies to all of the Binaryen tools (including e.g. wasm-opt) and is because Binaryen regenerates the source map after it does its transformations (because of course transformations change the binary and therefore the mappings). But some information can just be passed through, including the list of source files in sources their content in sourcesContent (basically everything other than names and mappings). Currently the symbol and filename info just hangs off the Module object and gets read from and written into the source map during wasm binary reading and writing. It seems like it would be straightforward to add another field or two that passes directly through to the output. If the size of the sources gets to be too unwieldy, we could maybe represent them as indices or file offsets or something and pass them a little more directly/incrementally from the input to the output rather than keeping them attached to the Module in memory in between. But I'm not sure whether that would really be an issue or not.

dschuff avatar Apr 03 '25 20:04 dschuff

When can we expect a release with the fix in 7473? The latest release (123) came out on March 25 😬

amaanq avatar Aug 30 '25 22:08 amaanq

I just released version 124 now,

https://github.com/WebAssembly/binaryen/releases/tag/version_124

kripken avatar Sep 02 '25 20:09 kripken

ty!!

amaanq avatar Sep 02 '25 20:09 amaanq