A (Nearly-Complete) Linux API for WebAssembly!
This is a result of work published at EuroSys 2025 on Empowering WebAssembly with Thin Kernel Interfaces (arxiv version available here)
This repo contains all the compiler and engine prototypes for an implementation of the WebAssembly Linux Interface. A list of supported syscalls can be found here
-
Install dependencies with
sudo ./apt-install-deps.sh
or equivalent packages -
Setup toolchain configs:
python3 toolchains/gen_toolchains.py
There are four major toolchain components, that may be incrementally built:
I just want to run WALI Wasm executables!:
I want to compile/build WALI executables!:
I want to AoT compile the Wasm executables to go fast!
We include a baseline implementation in WAMR. To build:
git submodule update --init wasm-micro-runtime
# Generates `iwasm` symlink in root directory
make iwasm
See examples/precompiled for runnable WALI binaries.
WALI Wasm/AoT binaries can be executed like ELF files with iwasm
(e.g. ./bash.wasm --norc
).
This is recommended since it simplifies execution and is necessary to build some applications out-of-the-box.
To do this, run:
cd misc
source gen_iwasm_wrapper.sh
# Specify '-p' option to register with systemd-binfmt for reboot survival. Default binfmt_register does not survive system reboots
sudo ./binfmt_register.sh -p
For more info about miscellaneous binary formats and troubleshooting, see here
git submodule update --init llvm-project
make wali-compiler
NOTE: Building the LLVM suite takes a long time and can consume up to 150GB of disk. The compiler is essential if you want to rebuild libc or build applications.
git submodule update --init wali-musl
make libc
NOTE: Only the following 64-bit architectures are supported: x86-64
, aarch64
, riscv64
. Future iterations will include a larger set of ISAs.
Generates faster ahead-of time compiled executables. For the WAMR implementation, build with:
make wamrc
The wamrc
symlink can be used as follows:
# --enable-multi-thread flag is needed for thread support
wamrc --enable-multi-thread -o <destination-aot-file> <source-wasm-file>
Refer to WAMR compiler docs for more info.
Setup appropriate toolchain files:
python3 toolchains/gen_toolchains.py
For additional information on using/customizing toolchains, see toolchains
You can use the convenience bash script in the examples directory. For instance:
cd examples
./compile-wali-standalone.sh -o printf.wasm printf.c
# Run the binary. Can just run `printf.wasm` if miscellaneous binary format is setup
../iwasm printf.wasm
Run make tests
. WALI executables are generated in tests/wasm
Note: Preliminary support for a
wasm32-wali-linux-musl
target has been upstreamed to rustc! Support for this target requires several ecosystem components to ratchet up to something usable long-term stability, and may hence currently be broken. Use the below out-of-tree build process for rustc if you need a stable target as a proof-of-concept.
We support a custom Rust compiler with a wasm32-wali-linux-musl
target.
Existing cargo
and rustup
are required for a successful build.
To build rustc
, run:
make rustc
This adds a new toolchain to rustup
named wali
with the new target.
To compile applications:
cargo +wali build --target=wasm32-wali-linux-musl
Note: Many applications will currently require a custom libc to be patched into
Cargo.toml
for the out-of-tree build.
The WALI for WebAssembly aims to push lightweight virtualization down to prevalent, low-level Linux applications. WALI adopts a layering approach to API design, allowing WASI (and other arbitrary Wasm APIs) to be virtualized over it, establishing infrastructure for Wasm both in research and industry.
Building and running Wasm binaries is now trivial with WALI, while improving ecosystem security by layering Wasm APIs
- Wasm possesses different runtime properties than some lower level languages like C (type-safety, sandboxing, etc.). The operation of WALI on these applications may differ as listed here
- Zenodo Ubuntu 22.04 VM artifact for experimenting with WALI
- Syscall Information Table
- Related Work: Verifying System Interfaces Paper