Building from Source

Installing Rustup

Building Wasmer from source requires Rust 1.45+.
The easiest way to install Rust on your system is via Rustup. To get Rustup on Linux and macOS, you can run the following:
1
curl https://sh.rustup.rs -sSf | sh
Copied!
To install Rust on Windows, download and run rustup-init.exe, then follow the onscreen instructions.

Installing Additional Dependencies

Windows

Windows support is fully supported. WASI is fully supported, but Emscripten support is in the works.
    1.
    Install Visual Studio​
    2.
    Install Rust for Windows​
    3.
    Install Git for Windows. Allow it to add git.exe to your PATH(default settings for the installer are fine).
    4.
    (optional) Install LLVM 11.0​

Building the Wasmer Runtime

Wasmer is built with Cargo, the Rust package manager.
First, let's clone Wasmer:
1
git clone https://github.com/wasmerio/wasmer.git
2
cd wasmer
Copied!
Wasmer supports three different compilers at the moment:

Singlepass Compiler

Build Wasmer:
1
make build-wasmer
Copied!
Note: you should see this Enabled Compilers: singlepass in console.
You may disable Singlepass compiler with export ENABLE_SINGLEPASS=0.

Cranelift Compiler

The Cranelift compiler will work if you are in a X86 or ARM machine, so you don't need to do anything in your system to enable it.
1
make build-wasmer
Copied!
Note: should see this as the first line in the console: Enabled Compilers: cranelift
You may disable Cranelift compiler with export ENABLE_CRANELIFT=0.

LLVM Compiler

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
    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
1
make build-wasmer
Copied!
Note: you should see this in the console: Enabled Compilers: llvm
You may disable LLVM compiler with export ENABLE_LLVM=0.

All compilers

Once you have LLVM and Rust, you can just run:
1
make build-wasmer
Copied!
Note: you should see this in the console: Enabled Compilers: singlepass cranelift llvm

Running your Wasmer binary

Once you run the make build-wasmer command, you will have a new binary ready to be used!
1
./target/release/wasmer quickjs.wasm
Copied!

Building Wasmer C-API from source

Wasmer provides a pre-compiled version for the C-API on its release page.
However, you can also compile the shared library from source:
1
make build-capi
Copied!
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:
1
make package-capi
Copied!
This command will generate a package directory, that you can then use easily in the Wasmer C API examples.
1
package/
2
lib/
3
libwasmer.so
4
headers/
5
wasm.h
6
wasmer.h
Copied!
By default, the Wasmer C API shared library will include all the compilers and engines available in the system where is built. Defaulting to cranelift and the universal engine if available.
You can generate the C-API for a specific compiler and engine with:
    Singlepass:
      Universal: make build-capi-singlepass-universal
      Native Engine: not yet available ⚠️
    Cranelift:
      Universal: make build-capi-cranelift-universal
      Native Engine: make build-capi-cranelift-native
    LLVM: make build-capi-llvm
      Universal: make build-capi-llvm-universal
      Native Engine: make build-capi-llvm-native
Last modified 3mo ago