[wasm-opt] `--minify-imports-and-exports-and-modules` does not report module renames.
还没有人认领这个 Issue。
评估
调研方向
首先使用提供的 test.wat、wat2wasm 命令和 --minify-imports-and-exports-and-modules 标志,通过 wasm-opt 版本 123 重现该问题。检查该标志的映射输出,并将其与 wasm2wat 输出进行比较;当 stdout 报告模块和函数的重命名(包括合并后的模块名称)时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
When using wasm-opt with the --minify-imports-and-exports-and-modules flag, the tool correctly minifies both the import module names and the import function names. It often merges multiple import modules into a single new minified name.
However, the mapping printed to stdout is incomplete. It includes the remapping for the function names but completely omits the remapping for the module names. This makes it impossible for tools that rely on this map to correctly patch the host JavaScript environment, breaking the application.
Environment
wasm-optVersion:wasm-opt version 123
Minimal Reproducible Example (MRE)
1. Input .wat file (test.wat):
This file defines a module that imports two functions from two different, uniquely named modules.
(module
(type (;0;) (func))
(import "long_module_name_a" "long_function_name_foo" (func (;0;) (type 0)))
(import "long_module_name_b" "long_function_name_bar" (func (;1;) (type 0)))
)
2. Assemble to .wasm:
wat2wasm test.wat -o test.wasm
3. Run wasm-opt:
wasm-opt test.wasm -o output.wasm --minify-imports-and-exports-and-modules
Results
Actual stdout Output:
The tool only prints the mapping for the function names:
long_function_name_foo => a
long_function_name_bar => b
Actual Contents of output.wasm (decompiled with wasm2wat):
The output Wasm shows that the module names were also minified and merged into "a":
(module
(type (;0;) (func))
(import "a" "a" (func (;0;) (type 0)))
(import "a" "b" (func (;1;) (type 0)))
)
Expected Behavior
The stdout mapping should be complete and reflect all minification operations performed on the import/export interface. A correct and unambiguous output would look something like this:
long_module_name_a => a
long_module_name_b => a
long_function_name_foo => a
long_function_name_bar => b
This would provide all the necessary information for a host environment to correctly wire up the minified module.
- 主要语言
- WebAssembly
- 星标
- 8.6k
- 派生
- 885
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 77
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
WebAssembly/binaryen 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
WebAssembly/binaryen#9135 · 1 条评论 ·
-
难度 2/5 半天 新手友好度 76/100
WebAssembly/binaryen#9018 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
WebAssembly/binaryen#9133 ·
-
难度 4/5 3-5 天 新手友好度 52/100
WebAssembly/binaryen#9123 ·
-
难度 5/5 一周以上 新手友好度 35/100
WebAssembly/binaryen#9122 ·
查看 WebAssembly/binaryen 的全部 Issue
相似的 Issue
-
area: harness bug status: needs-triage
难度 2/5 1-3 小时 新手友好度 75/100
Human-Agent-Society/reef#625 ·
-
module: core
难度 2/5 1-3 小时 新手友好度 75/100
bigbluebutton/bigbluebutton#25849 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
vercel-labs/just-bash#464 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
area:sandbox documentation enhancement platform:linux
难度 1/5 1 小时以内 新手友好度 85/100
anthropics/claude-code#96664 ·