summaryrefslogtreecommitdiff
path: root/test/lit/help
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-05-16 11:03:45 -0700
committerGitHub <noreply@github.com>2023-05-16 11:03:45 -0700
commit972e659bf59740c3ee44129812f95bec143d01a6 (patch)
treef86d70fa692a45e3dfbf951b0d1af06204d4ecf7 /test/lit/help
parent44cd751d9feda7c4b4b6c9d6af1e71541b90abac (diff)
downloadbinaryen-972e659bf59740c3ee44129812f95bec143d01a6.tar.gz
binaryen-972e659bf59740c3ee44129812f95bec143d01a6.tar.bz2
binaryen-972e659bf59740c3ee44129812f95bec143d01a6.zip
Reintroduce wasm-merge (#5709)
We used to have a wasm-merge tool but removed it for a lack of use cases. Recently use cases have been showing up in the wasm GC space and elsewhere, as people are using more diverse toolchains together, for example a project might build some C++ code alongside some wasm GC code. Merging those wasm files together can allow for nice optimizations like inlining and better DCE etc., so it makes sense to have a tool for merging. Background: * Removal: #1969 * Requests: * wasm-merge - why it has been deleted #2174 * Compiling and linking wat files #2276 * wasm-link? #2767 This PR is a compete rewrite of wasm-merge, not a restoration of the original codebase. The original code was quite messy (my fault), and also, since then we've added multi-memory and multi-table which makes things a lot simpler. The linking semantics are as described in the "wasm-link" issue #2767 : all we do is merge normal wasm files together and connect imports and export. That is, we have a graph of modules and their names, and each import to a module name can be resolved to that module. Basically, like a JS bundler would do for JS, or, in other words, we do the same operations as JS code would do to glue wasm modules together at runtime, but at compile time. See the README update in this PR for a concrete example. There are no plans to do more than that simple bundling, so this should not really overlap with wasm-ld's use cases. This should be fairly fast as it works in linear time on the total input code. However, it won't be as fast as wasm-ld, of course, as it does build Binaryen IR for each module. An advantage to working on Binaryen IR is that we can easily do some global DCE after merging, and further optimizations are possible later.
Diffstat (limited to 'test/lit/help')
-rw-r--r--test/lit/help/wasm-merge.test149
1 files changed, 149 insertions, 0 deletions
diff --git a/test/lit/help/wasm-merge.test b/test/lit/help/wasm-merge.test
new file mode 100644
index 000000000..541f37d5a
--- /dev/null
+++ b/test/lit/help/wasm-merge.test
@@ -0,0 +1,149 @@
+;; RUN: wasm-merge --help | filecheck %s
+;; CHECK: ================================================================================
+;; CHECK-NEXT: wasm-merge INFILE1 NAME1 INFILE2 NAME2 [..]
+;; CHECK-NEXT:
+;; CHECK-NEXT: Merge wasm files into one.
+;; CHECK-NEXT:
+;; CHECK-NEXT: For example,
+;; CHECK-NEXT:
+;; CHECK-NEXT: wasm-merge foo.wasm foo bar.wasm bar -o merged.wasm
+;; CHECK-NEXT:
+;; CHECK-NEXT: will read foo.wasm and bar.wasm, with names 'foo' and 'bar' respectively, so if
+;; CHECK-NEXT: the second imports from 'foo', we will see that as an import from the first
+;; CHECK-NEXT: module after the merge. The merged output will be written to merged.wasm.
+;; CHECK-NEXT:
+;; CHECK-NEXT: Note that filenames and modules names are interleaved (which is hopefully less
+;; CHECK-NEXT: confusing).
+;; CHECK-NEXT: ================================================================================
+;; CHECK-NEXT:
+;; CHECK-NEXT:
+;; CHECK-NEXT: wasm-merge options:
+;; CHECK-NEXT: -------------------
+;; CHECK-NEXT:
+;; CHECK-NEXT: --output,-o Output file (stdout if not specified)
+;; CHECK-NEXT:
+;; CHECK-NEXT: --rename-export-conflicts,-rec Rename exports to avoid conflicts (rather
+;; CHECK-NEXT: than error)
+;; CHECK-NEXT:
+;; CHECK-NEXT: --skip-export-conflicts,-sec Skip exports that conflict with previous
+;; CHECK-NEXT: ones
+;; CHECK-NEXT:
+;; CHECK-NEXT: --emit-text,-S Emit text instead of binary for the
+;; CHECK-NEXT: output file
+;; CHECK-NEXT:
+;; CHECK-NEXT: --debuginfo,-g Emit names section and debug info
+;; CHECK-NEXT:
+;; CHECK-NEXT:
+;; CHECK-NEXT: Tool options:
+;; CHECK-NEXT: -------------
+;; CHECK-NEXT:
+;; CHECK-NEXT: --mvp-features,-mvp Disable all non-MVP features
+;; CHECK-NEXT:
+;; CHECK-NEXT: --all-features,-all Enable all features
+;; CHECK-NEXT:
+;; CHECK-NEXT: --detect-features (deprecated - this flag does nothing)
+;; CHECK-NEXT:
+;; CHECK-NEXT: --quiet,-q Emit less verbose output and hide trivial
+;; CHECK-NEXT: warnings.
+;; CHECK-NEXT:
+;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
+;; CHECK-NEXT: purposes.
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-threads Enable atomic operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-threads Disable atomic operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-mutable-globals Enable mutable globals
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-mutable-globals Disable mutable globals
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-nontrapping-float-to-int Enable nontrapping float-to-int
+;; CHECK-NEXT: operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-nontrapping-float-to-int Disable nontrapping float-to-int
+;; CHECK-NEXT: operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-simd Enable SIMD operations and types
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-simd Disable SIMD operations and types
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-bulk-memory Enable bulk memory operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-tail-call Enable tail call operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-tail-call Disable tail call operations
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-reference-types Enable reference types
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-reference-types Disable reference types
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-multivalue Enable multivalue functions
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-multivalue Disable multivalue functions
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-gc Enable garbage collection
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-gc Disable garbage collection
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-memory64 Enable memory64
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-memory64 Disable memory64
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-gc-nn-locals Enable GC non-null locals
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-gc-nn-locals Disable GC non-null locals
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-relaxed-simd Enable relaxed SIMD
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-relaxed-simd Disable relaxed SIMD
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-extended-const Enable extended const expressions
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-multi-memories Enable multi-memories
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-multi-memories Disable multi-memories
+;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-typed-function-references Deprecated compatibility flag
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-typed-function-references Deprecated compatibility flag
+;; CHECK-NEXT:
+;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
+;; CHECK-NEXT: correct
+;; CHECK-NEXT:
+;; CHECK-NEXT: --pass-arg,-pa An argument passed along to optimization
+;; CHECK-NEXT: passes being run. Must be in the form
+;; CHECK-NEXT: KEY@VALUE
+;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
+;; CHECK-NEXT:
+;; CHECK-NEXT: General options:
+;; CHECK-NEXT: ----------------
+;; CHECK-NEXT:
+;; CHECK-NEXT: --version Output version information and exit
+;; CHECK-NEXT:
+;; CHECK-NEXT: --help,-h Show this help message and exit
+;; CHECK-NEXT:
+;; CHECK-NEXT: --debug,-d Print debug information to stderr
+;; CHECK-NEXT: