A (Nearly-Complete) Linux API for WebAssembly!
The WALI website contains information about the overarching project and specification. This repo contains the compiler and engine prototypes for the WALI implementation.
- Clone the repository:
git clone https://github.com/arjunr2/WALI.git - Setup toolchain configs:
python3 toolchains/gen_toolchains.py
From here, parts of this project may be incrementally built based on needs:
- I want to run WALI Wasm executables!: WALI Engine
- I want to compile/build WALI executables!: Compile Toolchain
We include a baseline implementation of WALI in WAMR. See examples/precompiled for runnable WALI binaries.
# 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 -pMore info on miscellaneous binary formats and troubleshooting can be found here
# 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..>First build the LLVM backend for WALI:
git submodule update --init --depth=1 llvm-project
make wali-compilerNote: Building the LLVM suite takes a long time and can consume up to 150GB of disk.
Then, we can proceed to build the musl sysroot:
git submodule update --init wali-musl
make libcNote: Only the following 64-bit architectures are supported:
x86-64,aarch64,riscv64. Future iterations will include a larger set of ISAs.
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>AoT files for WAMR can be run from the command line just like Wasm files.
Note: Ensure initial setup is completed. For additional information on using/customizing toolchains, see toolchains
A simple "hello world" can be built and run as below:
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.wasmYou can find more sample programs in examples/mini.
To build and run the unit test suite:
cd tests
# Ensure iwasm, libc, and compiler toolchains were all built prior to this
make && python3 run_tests.py- Compiler ports of WALI for other languages.
- Zenodo Ubuntu 22.04 VM artifact for experimenting with WALI
