Skip to content

arjunr2/WALI

Repository files navigation

Webassembly Linux Interface (WALI)

WebAssembly Linux Interface

A (Nearly-Complete) Linux API for WebAssembly!

This work is published at EuroSys 2025 on Empowering WebAssembly with Thin Kernel Interfaces. This repo contains all the compiler and engine prototypes for an implementation of the WebAssembly Linux Interface and a brief description of the project's goals. The list of currently supported syscalls can be found here

Initial Setup

  • Clone the repository: git clone https://github.com/arjunr2/WALI.git
  • Setup toolchain configs: python3 toolchains/gen_toolchains.py

Component Setup

There are four major toolchain components, that may be incrementally built:

I just want to run WALI Wasm executables!:

  1. WALI Engine

I want to compile/build WALI executables!:

  1. WALI LLVM Toolchain
  2. WALI Sysroot

I want to AoT compile the Wasm executables to go fast!

  1. AoT Compiler

1. WALI Engine

We include a baseline implementation in WAMR. See examples/precompiled for runnable WALI binaries.

Native Linux Host

# Install dependencies
sudo ./apt-install-deps.sh
git submodule update --init wasm-micro-runtime
# Generates `iwasm` symlink in root directory
make iwasm

[Optional, but Recommended] Wasm as a Miscellaneous Binary Format: By registering Wasm/AoT binaries as a miscellenous binary format with the above engine, .wasm files can be executed like ELF files (e.g. ./bash.wasm --norc). This is necessary to build some applications that execute intermediate binaries. To do this, run:

# Specify '-p' option to register with systemd-binfmt for reboot survival. Default binfmt_register does not survive system reboots
sudo ./toolchains/binfmt/binfmt_register.sh -p

More info on miscellaneous binary formats and troubleshooting can be found here

Docker Environment for Non-Linux Hosts

# Building the image
docker build -t wali -f runtime.Dockerfile .
# Running binaries with the image
docker run --rm -it -w /dir -v (pwd):/dir wali <prog.wasm> <args..>

2. WALI LLVM Toolchain

git submodule update --init --depth=1 llvm-project
make wali-compiler

Note: Building the LLVM suite takes a long time and can consume up to 150GB of disk.

3. WALI Sysroot

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.

4. AoT Compiler

Generate faster ahead-of time (AoT) compiled executables. For the WAMR implementation, additional details can be found on the WAMR compiler docs:

# Build wamrc
make wamrc
# Using wamrc
wamrc --enable-multi-thread -o <destination-aot-file> <source-wasm-file>

Building WALI Applications

Ensure initial setup is completed.

Note: For additional information on using/customizing toolchains, see toolchains

Hello World

cd examples
# This script sets up standard build flags for the compiler toolchain.
# For WALI binaries without main/start functions, refer to `print_nostart.c` instead
./compile-wali-standalone.sh -o print.wasm print.c
# Run the binary (or `./print.wasm` if miscellaneous binary format is setup)
../iwasm print.wasm

Unit Tests

# WALI executables are located in `./tests/wasm`
make tests

Additional Resources

About

A low-level virtualization interface for Linux-based systems using WebAssembly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published