Building Wasmer from source requires Rust 1.67+.
The easiest way to install Rust on your system is via Rustup. To get Rustup on Linux and macOS, you can run the following:
curl https://sh.rustup.rs -sSf | sh
Note
To install Rust on Windows, download and run rustup-init.exe, then follow the on-screen instructions.
Windows is fully supported by Wasmer. WASI is also fully supported.
- Install Visual Studio
- Install Rust for Windows
- Install Git for Windows. Allow it to add
git.exe
to your PATH (default settings for the installer are fine). - (optional) Install LLVM 11.0
Wasmer is built with Cargo, the Rust package manager.
First, let's clone Wasmer:
git clone https://github.com/wasmerio/wasmer.git
cd wasmer
Wasmer supports three different compilers at the moment:
Build Wasmer:
make build-wasmer
Note: you should see this Enabled Compilers: singlepass
in console.
You may disable Singlepass compiler with export ENABLE_SINGLEPASS=0
.
The Cranelift compiler will work if you are on a X86 or ARM machine. It will be detected automatically, so you don't need to do anything to your system to enable it.
make build-wasmer
Note: should see this as the first line in the console:
Enabled Compilers: cranelift
You may disable the Cranelift compiler with export ENABLE_CRANELIFT=0
.
If you want support for the Wasmer LLVM compiler, then you will also need to ensure:
- Ensure that LLVM 10.0.x > is installed on your system
- You can refer to LLVM install instructions
- You can also download and use a prebuilt LLVM binary
- In case
llvm-config
is not accessible, set the correct environment variable for LLVM to access: For example, the environment variable for LLVM 11.0.x would be:LLVM_SYS_110_PREFIX=/path/to/unpacked/llvm-11.0
And create a Wasmer release
make build-wasmer
Note: you should see this in the console:
Enabled Compilers: llvm
You may disable the LLVM compiler with export ENABLE_LLVM=0
.
Once you have LLVM and Rust, you can just run:
make build-wasmer
Note: you should see this in the console:
Enabled Compilers: singlepass cranelift llvm
Once you run the make build-wasmer
command, you will have a new binary ready to be used!
./target/release/wasmer quickjs.wasm
Wasmer provides a pre-compiled version for the C-API on its release page.
However, you can also compile the shared library from source:
make build-capi
This will generate the shared library (depending on your system):
- Windows:
target/release/libwasmer_c_api.dll
- macOS:
target/release/libwasmer_c_api.dylib
- Linux:
target/release/libwasmer_c_api.so
If you want to generate the library and headers for using them easily, you can execute:
make package-capi
This command will generate a package
directory, that you can then use easily in the Wasmer C API examples.
package/
lib/
libwasmer.so
headers/
wasm.h
wasmer.h
Important
By default, the Wasmer C API shared library will include all the backends available in the system where is built.
Defaulting to cranelift
if available.
You can generate the C-API for a specific compiler and engine with:
make build-capi-{ENGINE}