This repo serves to prototype an implementation of the WebAssembly Linux Interface. For current range of support, refer here
WALI is a complete(ish?) abstraction over Linux for WebAssembly that aims to push lightweight virtualization down to even low-level system applications. WALI adopts a layering approach to API design, establishing infrastructure for facilitating WebAssembly-oriented research by virtualizing high-level APIs and seamless build-run-deploy workflows of arbitrary applications. We create a custom modified C standard library (musl libc) that uses WALI and produce a baseline implementation in WAMR
Before proceeding, make sure all dependencies are installed with sudo ./apt-install-deps.sh
.
There are four major toolchain components, that may be incrementally built based on requirements:
I just want to run WALI apps!:
I want to compile/build WALI apps!:
I want to AoT compile WALI apps to go fast!
We have a baseline implementation in WAMR. To build:
git submodule update --init wasm-micro-runtime
make iwasm
An iwasm
symlink executable should be generated in the root directory that can execute WALI binaries (e.g. ./iwasm -v=0 --stack-size=524288 <path-to-wasm-file>
).
See Sample Applications for test binaries.
WALI Wasm/AoT binaries can be executed like ELF files with iwasm
(e.g. ./bash.wasm --norc
)!
This will simplify all WALI toolchain builds and is required to compile some applications in our repo.
To do this, run:
cd misc
source gen_iwasm_wrapper.sh
# Default binfmt_register does not survive reboots in the system
# Specify '-p' option to register with systemd-binfmt for reboot survival
sudo ./binfmt_register.sh -p
More information about miscellaneous binary formats and troubleshooting can be found 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.
To build libc:
git submodule update --init wali-musl
make libc
We currently support 64-bit architectures (x86-64, aarch64, riscv64) with hopes to expand to more architectures.
Generates faster ahead-of time compiled executables. For our WAMR implementation, build as:
make wamrc
Refer to WAMR compiler
for any extra information on the build.
Once completed, a symlink to wamrc
is generated in the root directory:
wamrc --enable-multi-thread -o <destination-aot-file> <source-wasm-file> # We require --enable-multi-thread flag for threads
We provide three configuration files with toolchain requirements, drastically easing plug-in into major builds
- Bash: Source the wali_config.sh (see tests/compile-wali.sh)
- Make: Include wali_config.mk (see applications/Makefile)
- CMake: The wali_config_toolchain.cmake file can be used directly in
CMAKE\_TOOLCHAIN\_FILE
- Tests can be built with
make tests
. WALI executables are located intests/wasm
-- corresponding native ELF files intests/elf
can be used to compare against the WASM output - Apps: The sample-apps directory has few several popular prebuilt binaries to run
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
until potential upstreaming is possible.
- 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
- This paper and its related work section, especially the bit labeled "Modeling and verifying system interfaces"