fix(fuse): coalesce + index-remap the name section under --preserve-names (#328)#333
Conversation
…ames (#328) `--preserve-names` copied every input module's `name` custom section verbatim into the fused module. With multiple modules that produced (a) DUPLICATE `name` sections — llvm-dwarfdump rejects the whole module (`out of order section type: 0`) — and (b) function-name entries carrying each source module's PRE-fusion indices, so names labelled the wrong fused functions. `wasm-tools validate` passes, so it was silent. Same class as #222 (producers), never applied to `name`. Fix (the #222 pattern + index remapping): - `MergedModule` gains `fused_function_names: BTreeMap<u32, String>`. - At the per-module custom-section merge (merger.rs), `name` is no longer copied verbatim; `accumulate_remapped_function_names` parses it and remaps each function-name entry from `(comp, module, orig_idx)` into the fused index space via `function_index_map` (already populated by the preceding function merge). Entries with no mapping (dead/internalized) are dropped — never a wrong index (LS-D-1). Non-function subsections are dropped in this pass. - At encode (`encode_output`, `preserve_names` branch) exactly ONE coalesced `name` section is emitted from the accumulator, in the LLVM-required order. So the output carries a single `name` section whose indices are all in the fused space. Pinned by `accumulate_remapped_function_names_remaps_and_drops_unmapped`. Tier-5 (merger.rs, adapter/): needs a Mythos discover pass before merge. Refs #328. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mythos delta-pass requiredThis PR modifies one or more Tier-5 source files (per Before merge, run the Mythos discover protocol on the
Why this gate exists: LS-A-10 The gate check on this PR will pass once the label is |
LS-N verification gate✅ 59/59 approved LS entries verified
Approved Failed LS entries(none) Missing regression tests(none) Updated automatically by |
Mythos delta-pass (auto)❌ 1 finding(s) across 2 Tier-5 file(s)
Auto-run via |
Mythos discover pass: NO FINDINGS (manual)The automated A full manual adversarial discover pass on this change (
Adding |
First fix of the v0.39.0 combined release.
What
--preserve-namesemitted duplicatenamecustom sections (llvm-dwarfdump rejects the module) with stale, pre-fusion function indices (wrong labels). Now it emits one coalescednamesection whose indices are remapped into the fused space. Same class as #222 (producers), applied toname— plus the index remap producers didn't need.How
MergedModule.fused_function_names: BTreeMap<u32,String>accumulates fused-indexed names.merger.rs:nameis remapped viafunction_index_mapat the per-module merge (accumulate_remapped_function_names) instead of copied verbatim; unmapped (dead) entries dropped — never a wrong index (LS-D-1); non-function subsections dropped this pass.encode_output: emits exactly onenamesection from the accumulator underpreserve_names, in the LLVM-required order.Verification
accumulate_remapped_function_names_remaps_and_drops_unmapped(remaps mapped indices; drops unmapped).Gate
Tier-5 (
merger.rs,adapter/) → needs a Mythos discover pass +mythos-pass-donebefore merge (in progress). rivet requirement scopedrelease: v0.39.0to follow. Held for your merge nod.Refs #328.
🤖 Generated with Claude Code