brson / wasm-opt-rs

Rust bindings for Binaryen's wasm-opt
Apache License 2.0
64 stars 10 forks source link
rust wasm webassembly

Rust bindings for Binaryen's wasm-opt

github crates.io docs.rs build status

wasm-opt is a component of the Binaryen toolkit that optimizes WebAssembly modules. It is written in C++.

This project provides a Rust crate that builds wasm-opt and:

1) makes its command-line interface installable via cargo install, 2) provides an API to access it programmatically.

Installing the binary

cargo install wasm-opt --locked

It should behave exactly the same as wasm-opt installed from other sources.

Using the library

See the API documentation.

Building from source

git clone https://github.com/brson/wasm-opt-rs
cd wasm-opt-rs
git submodule update --init --recursive
cargo build && cargo test

Toolchain requirements

Requires Rust 1.48+ and a C++ compiler with C++17 support. It does not require CMake or other C++ build tools.

These are the earliest C++ compiler versions known to work:

Limitations

Versioning

Binaryen uses a single monotonically-increasing number for versions. This crate uses the semver minor version to track the Binaryen version, so e.g. the wasm-opt crate version 0.110.0 corresponds to Binaryen 110. Point releases are used for bugfixes.

Since minor version bumps of crates earlier than 1.0.0 are considered breaking, users need to explicitly upgrade versions of wasm-opt to get new Binaryen releases, and upgrades may have breaking API changes, though we don't anticipate significant changes.

Thanks

This project was created thanks to a grant from the Web3 Foundation.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Binaryen itself, code from which is compiled and linked by this project, is licensed under the terms of the Apache License, Version 2.0.