Skip to content

Commit 25d3540

Browse files
authored
[wasm-split] Support --symbolmap for --multi-split (#7791)
1 parent baa841a commit 25d3540

File tree

5 files changed

+104
-9
lines changed

5 files changed

+104
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ Current Trunk
1616
-------------
1717

1818
- `wasm-split`'s `--multi-split` mode now supports more options:
19-
`--no-placeholders`, `--import-namespace`, `--emit-module-names`, and
20-
`--emit-text`. Because `--no-placeholders` is false by default and until now
21-
`--multi-split` didn't use placeholders at all, this is a breaking change. If
22-
you want to continue to do multi-split without placeholders, you need to
23-
explicitly specify `--no-placeholders`.
19+
`--no-placeholders`, `--import-namespace`, `--emit-module-names`,
20+
`--emit-text`, and `--symbolmap`. Because `--no-placeholders` is false by
21+
default and until now `--multi-split` didn't use placeholders at all, this is
22+
a breaking change. If you want to continue to do multi-split without
23+
placeholders, you need to explicitly specify `--no-placeholders`.
2424
- Add a `--string-lifting` pass that raises imported string operations and
2525
constants into stringref in Binaryen IR (which can then be fully optimized,
2626
and typically lowered back down with `--string-lowering`).

src/tools/wasm-split/split-options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ WasmSplitOptions::WasmSplitOptions()
204204
"",
205205
"Write a symbol map file for each of the output modules.",
206206
WasmSplitOption,
207-
{Mode::Split},
207+
{Mode::Split, Mode::MultiSplit},
208208
Options::Arguments::Zero,
209209
[&](Options* o, const std::string& argument) { symbolMap = true; })
210210
.add(

src/tools/wasm-split/wasm-split.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,21 @@ void multiSplitModule(const WasmSplitOptions& options) {
431431
}
432432
config.secondaryFuncs = std::set<Name>(funcs.begin(), funcs.end());
433433
auto splitResults = ModuleSplitting::splitFunctions(wasm, config);
434-
// TODO: symbolMap, placeholderMap
434+
// TODO: placeholderMap
435435
auto moduleName =
436436
options.outPrefix + mod + (options.emitBinary ? ".wasm" : ".wast");
437+
if (options.symbolMap) {
438+
writeSymbolMap(*splitResults.secondary, moduleName + ".symbols");
439+
}
437440
if (options.emitModuleNames) {
438441
splitResults.secondary->name = Path::getBaseName(moduleName);
439442
}
440443
writeModule(*splitResults.secondary, moduleName, options);
441444
}
445+
if (options.symbolMap) {
446+
writeSymbolMap(wasm, options.output + ".symbols");
447+
}
448+
442449
writeModule(wasm, options.output, options);
443450
}
444451

test/lit/help/wasm-split.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
;; CHECK-NEXT: --secondary-output,-o2 [split] Output file for the secondary
6565
;; CHECK-NEXT: module.
6666
;; CHECK-NEXT:
67-
;; CHECK-NEXT: --symbolmap [split] Write a symbol map file for each
68-
;; CHECK-NEXT: of the output modules.
67+
;; CHECK-NEXT: --symbolmap [split, multi-split] Write a symbol map
68+
;; CHECK-NEXT: file for each of the output modules.
6969
;; CHECK-NEXT:
7070
;; CHECK-NEXT: --no-placeholders [split, multi-split] Do not import
7171
;; CHECK-NEXT: placeholder functions. Calls to secondary
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
;; RUN: wasm-split -all --multi-split %s --manifest %S/multi-split.wast.manifest --out-prefix=%t --symbolmap -o %t.wasm
2+
;; RUN: filecheck %s --check-prefix PRIMARY-MAP < %t.wasm.symbols
3+
;; RUN: filecheck %s --check-prefix MOD1-MAP < %t1.wasm.symbols
4+
;; RUN: filecheck %s --check-prefix MOD2-MAP < %t2.wasm.symbols
5+
;; RUN: filecheck %s --check-prefix MOD3-MAP < %t3.wasm.symbols
6+
7+
;; PRIMARY-MAP: 0:placeholder_0
8+
;; PRIMARY-MAP: 1:placeholder_0_5
9+
;; PRIMARY-MAP: 2:placeholder_0_6
10+
;; PRIMARY-MAP: 3:trampoline_A
11+
;; PRIMARY-MAP: 4:B
12+
;; PRIMARY-MAP: 5:trampoline_B
13+
;; PRIMARY-MAP: 6:C
14+
15+
;; MOD1-MAP: 0:B
16+
;; MOD1-MAP: 1:C
17+
;; MOD1-MAP: 2:A
18+
19+
;; MOD2-MAP: 0:C
20+
;; MOD2-MAP: 1:trampoline_A
21+
;; MOD2-MAP: 2:B
22+
23+
;; MOD3-MAP: 0:trampoline_A
24+
;; MOD3-MAP: 1:trampoline_B
25+
;; MOD3-MAP: 2:C
26+
27+
(module
28+
(type $ret-i32 (func (result i32)))
29+
(type $ret-i64 (func (result i64)))
30+
(type $ret-f32 (func (result f32)))
31+
32+
(func $A (type $ret-i32) (result i32)
33+
(drop
34+
(call_ref $ret-i32
35+
(ref.func $A)
36+
)
37+
)
38+
(drop
39+
(call_ref $ret-i64
40+
(ref.func $B)
41+
)
42+
)
43+
(drop
44+
(call_ref $ret-f32
45+
(ref.func $C)
46+
)
47+
)
48+
(i32.const 0)
49+
)
50+
51+
(func $B (type $ret-i64) (result i64)
52+
(drop
53+
(call_ref $ret-i32
54+
(ref.func $A)
55+
)
56+
)
57+
(drop
58+
(call_ref $ret-i64
59+
(ref.func $B)
60+
)
61+
)
62+
(drop
63+
(call_ref $ret-f32
64+
(ref.func $C)
65+
)
66+
)
67+
(i64.const 0)
68+
)
69+
70+
(func $C (type $ret-f32) (result f32)
71+
(drop
72+
(call_ref $ret-i32
73+
(ref.func $A)
74+
)
75+
)
76+
(drop
77+
(call_ref $ret-i64
78+
(ref.func $B)
79+
)
80+
)
81+
(drop
82+
(call_ref $ret-f32
83+
(ref.func $C)
84+
)
85+
)
86+
(f32.const 0)
87+
)
88+
)

0 commit comments

Comments
 (0)