summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-04-24 14:51:43 -0700
committerGitHub <noreply@github.com>2024-04-24 14:51:43 -0700
commit2e7e9ddcef219a2a1124dfb7f7009602c42084df (patch)
tree10bf033aa324c7997314eec33adbd88c425d7e3a
parent39c9baf2c525d962a99183672a080147ef2e567c (diff)
downloadbinaryen-2e7e9ddcef219a2a1124dfb7f7009602c42084df.tar.gz
binaryen-2e7e9ddcef219a2a1124dfb7f7009602c42084df.tar.bz2
binaryen-2e7e9ddcef219a2a1124dfb7f7009602c42084df.zip
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.
-rw-r--r--src/tools/wasm-opt.cpp7
-rw-r--r--test/lit/deprecated-wat.wast24
-rw-r--r--test/lit/help/wasm-opt.test4
3 files changed, 35 insertions, 0 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 54a83d15a..32f9f1aad 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -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",
diff --git a/test/lit/deprecated-wat.wast b/test/lit/deprecated-wat.wast
new file mode 100644
index 000000000..401d3244b
--- /dev/null
+++ b/test/lit/deprecated-wat.wast
@@ -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))
+)
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 849469178..f7ee47c09 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -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: