Skip to content

Commit

Permalink
Add a flag to opt in to the old WAT parser (#6536)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlively authored Apr 24, 2024
1 parent 39c9baf commit 2e7e9dd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tools/wasm-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ int main(int argc, const char* argv[]) {
[&outputSourceMapUrl](Options* o, const std::string& argument) {
outputSourceMapUrl = argument;
})
.add(
"--deprecated-wat-parser",
"",
"Use the old, deprecated WAT parser. This option will be removed soon!",
WasmOptOption,
Options::Arguments::Zero,
[](Options*, const std::string&) { useNewWATParser = false; })
.add("--new-wat-parser",
"",
"Use the experimental new WAT parser",
Expand Down
24 changes: 24 additions & 0 deletions test/lit/deprecated-wat.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: wasm-opt --deprecated-wat-parser -all %s -S -o - | filecheck %s

(module
;; CHECK: (type $0 (func (param i32)))

;; CHECK: (type $1 (func (result i32)))

;; CHECK: (import "env" "bad" (func $wrong (type $0) (param i32)))

;; CHECK: (func $foo (type $1) (result i32)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
(func $foo (result i32)
;; Non-standard block result format
(block i32
(i32.const 0)
)
)

;; Non-standard import after declared function
(import $wrong "env" "bad" (param i32))
)
4 changes: 4 additions & 0 deletions test/lit/help/wasm-opt.test
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
;; CHECK-NEXT: --output-source-map-url,-osu Emit specified string as source
;; CHECK-NEXT: map URL
;; CHECK-NEXT:
;; CHECK-NEXT: --deprecated-wat-parser Use the old, deprecated WAT
;; CHECK-NEXT: parser. This option will be
;; CHECK-NEXT: removed soon!
;; CHECK-NEXT:
;; CHECK-NEXT: --new-wat-parser Use the experimental new WAT
;; CHECK-NEXT: parser
;; CHECK-NEXT:
Expand Down

0 comments on commit 2e7e9dd

Please sign in to comment.