Commit 63e5f28
`--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>
1 parent 15e25ad commit 63e5f28
3 files changed
Lines changed: 113 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12883 | 12883 | | |
12884 | 12884 | | |
12885 | 12885 | | |
| 12886 | + | |
12886 | 12887 | | |
12887 | 12888 | | |
12888 | 12889 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1812 | 1812 | | |
1813 | 1813 | | |
1814 | 1814 | | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
1815 | 1832 | | |
1816 | 1833 | | |
1817 | 1834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
| |||
989 | 998 | | |
990 | 999 | | |
991 | 1000 | | |
| 1001 | + | |
992 | 1002 | | |
993 | 1003 | | |
994 | 1004 | | |
| |||
2165 | 2175 | | |
2166 | 2176 | | |
2167 | 2177 | | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
2168 | 2196 | | |
2169 | 2197 | | |
2170 | 2198 | | |
| |||
3551 | 3579 | | |
3552 | 3580 | | |
3553 | 3581 | | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
3554 | 3616 | | |
3555 | 3617 | | |
3556 | 3618 | | |
3557 | 3619 | | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
3558 | 3651 | | |
3559 | 3652 | | |
3560 | 3653 | | |
| |||
3670 | 3763 | | |
3671 | 3764 | | |
3672 | 3765 | | |
| 3766 | + | |
3673 | 3767 | | |
3674 | 3768 | | |
3675 | 3769 | | |
| |||
5724 | 5818 | | |
5725 | 5819 | | |
5726 | 5820 | | |
| 5821 | + | |
5727 | 5822 | | |
5728 | 5823 | | |
5729 | 5824 | | |
| |||
0 commit comments