Add --emit-module-names to wasm-opt#8860
Conversation
The `wasm-split` command has this `--emit-module-names` flag already and this adds it to `wasm-opt` as well. Wasm runtimes may not know the URL where a wasm file came from, it may only be given the bytes. Currently e.g. V8 prints a V8 specific hash of the wasm file in stack traces. If we have the ability to keep module names, then it would print the module name (fallback if the url is not available) -- which would allow a stack trace decoding tool to tie the module name back to the right wasm module of an app.
|
|
It's not clear to me that the fix for that chromium issue constitutes a "simpler way of naming modules," so I'd be happy to have this flag added to |
Precisely. The V8 bug was closed by making V8 stack frames contain a hash of the module bytes via an V8-internal hash function -- outside tooling that gets a stack trace with those hash codes cannot do anything with them (it's not a wasm spec'ed hash code function) |
|
I've moved the option to |
| writer.setDebugInfo(options.passOptions.debugInfo); | ||
| if (options.emitModuleNames) { | ||
| writer.setEmitModuleName(true); | ||
| } |
There was a problem hiding this comment.
It looks like the PR adds the option to tool-options, but the implementation only in wasm-opt. So e.g. wasm-as declares the option now, but does nothing with it? I guess we don't have a shared writing path that would enable this flag for all tools at once. Given that, we should either add such a path, or go back to the previous state of the PR - that is, I think it's a bad result if wasm-as etc. declare options that don't work.
The
wasm-splitcommand has this--emit-module-namesflag already and this adds it towasm-optas well.Wasm runtimes may not know the URL where a wasm file came from, it may only be given the bytes.
If so, then e.g. V8 prints a wasm-runtime-specific hash of the wasm bytes in stack traces. If a stack trace has
frames of different wasm modules, these hashes do not allow mapping the frames back to the original wasm files.
If we have the ability to keep module names, then it would print the module name (**) (instead of the hash) --
which would allow a stack trace decoding tool to tie the module name back to the right wasm module of an app.
(**) It prefers the wasm file url. If that isn't available it falls back to module name. If that isn't available it falls back to hash of wasm bytes.