wasm-snip
replaces a WebAssembly function's body with an unreachable
.
Maybe you know that some function will never be called at runtime, but the
compiler can't prove that at compile time? Snip it! Then run
wasm-gc
again and all the functions it transitively called (which
could also never be called at runtime) will get removed too.
Very helpful when shrinking the size of WebAssembly binaries!
This functionality relies on the "name" section being present in the .wasm
file, so build with debug symbols:
[profile.release]
debug = true
To install the wasm-snip
executable, run
$ cargo install wasm-snip
For information on using the wasm-snip
executable, run
$ wasm-snip --help
To use wasm-snip
as a library, add this to your Cargo.toml
:
[dependencies.wasm-snip]
# Do not build the executable.
default-features = false
See docs.rs/wasm-snip for API documentation.
Licensed under either of
at your option.
See CONTRIBUTING.md for hacking.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.