Skip to content
/ WALI Public

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

License

Notifications You must be signed in to change notification settings

arjunr2/WALI

Repository files navigation

Webassembly Linux Interface (WALI)

WebAssembly Linux Interface

This repo serves to prototype an implementation of the WebAssembly Linux Interface. For current range of support, refer here

Overview

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

Component Setup

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!:

  1. WALI runtime

I want to compile/build WALI apps!:

  1. Clang compiler
  2. WALI Sysroot

I want to AoT compile WALI apps to go fast!

  1. AoT Compiler

WALI runtime

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.

WASM as a Miscellaneous Binary Format!

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

WALI LLVM compiler

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.

WALI Sysroot

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.

AoT Compiler

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

Adapting Build Systems to WALI

We provide three configuration files with toolchain requirements, drastically easing plug-in into major builds

  1. Bash: Source the wali_config.sh (see tests/compile-wali.sh)
  2. Make: Include wali_config.mk (see applications/Makefile)
  3. CMake: The wali_config_toolchain.cmake file can be used directly in CMAKE\_TOOLCHAIN\_FILE

Sample Applications

  • Tests can be built with make tests. WALI executables are located in tests/wasm -- corresponding native ELF files in tests/elf can be used to compare against the WASM output
  • Apps: The sample-apps directory has few several popular prebuilt binaries to run

Compiler Ports

Rust

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.

Resources

  • 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"

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

Contributors 3

  •  
  •  
  •