mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-06 12:48:20 +00:00
Wasmer Compiler - Cranelift
This is the wasmer-compiler-cranelift crate, which contains a
compiler implementation based on Cranelift.
Usage
First, add this crate into your Cargo.toml dependencies:
wasmer-compiler-cranelift = "1.0.0-alpha.1"
And then:
use wasmer::{Store, JIT};
use wasmer_compiler_cranelift::Cranelift;
let compiler = Cranelift::new();
// Put it into an engine and add it to the store
let store = Store::new(&JIT::new(&compiler).engine());
Note: you can find a full working example using Cranelift compiler here.
When to use Cranelift
We recommend using this compiler crate only for development proposes.
For production we recommend using wasmer-compiler-llvm as it offers
a much better runtime speed (50% faster on average).
Acknowledgments
This project borrowed some of the function lowering from cranelift-wasm.
Please check Wasmer ATTRIBUTIONS to further see licenses and other attributions of the project.