Skip to content

Commit 2e7e9dd

Browse files
authored
Add a flag to opt in to the old WAT parser (#6536)
This flag is intended to help users gracefully migrate to the new wat parser. It will be removed again not too long after the new wat parser is enabled by default in wasm-opt.
1 parent 39c9baf commit 2e7e9dd

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/tools/wasm-opt.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ int main(int argc, const char* argv[]) {
220220
[&outputSourceMapUrl](Options* o, const std::string& argument) {
221221
outputSourceMapUrl = argument;
222222
})
223+
.add(
224+
"--deprecated-wat-parser",
225+
"",
226+
"Use the old, deprecated WAT parser. This option will be removed soon!",
227+
WasmOptOption,
228+
Options::Arguments::Zero,
229+
[](Options*, const std::string&) { useNewWATParser = false; })
223230
.add("--new-wat-parser",
224231
"",
225232
"Use the experimental new WAT parser",

test/lit/deprecated-wat.wast

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
3+
;; RUN: wasm-opt --deprecated-wat-parser -all %s -S -o - | filecheck %s
4+
5+
(module
6+
;; CHECK: (type $0 (func (param i32)))
7+
8+
;; CHECK: (type $1 (func (result i32)))
9+
10+
;; CHECK: (import "env" "bad" (func $wrong (type $0) (param i32)))
11+
12+
;; CHECK: (func $foo (type $1) (result i32)
13+
;; CHECK-NEXT: (i32.const 0)
14+
;; CHECK-NEXT: )
15+
(func $foo (result i32)
16+
;; Non-standard block result format
17+
(block i32
18+
(i32.const 0)
19+
)
20+
)
21+
22+
;; Non-standard import after declared function
23+
(import $wrong "env" "bad" (param i32))
24+
)

test/lit/help/wasm-opt.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
;; CHECK-NEXT: --output-source-map-url,-osu Emit specified string as source
7373
;; CHECK-NEXT: map URL
7474
;; CHECK-NEXT:
75+
;; CHECK-NEXT: --deprecated-wat-parser Use the old, deprecated WAT
76+
;; CHECK-NEXT: parser. This option will be
77+
;; CHECK-NEXT: removed soon!
78+
;; CHECK-NEXT:
7579
;; CHECK-NEXT: --new-wat-parser Use the experimental new WAT
7680
;; CHECK-NEXT: parser
7781
;; CHECK-NEXT:

0 commit comments

Comments
 (0)