Skip to content

tamaroning/wanco

Repository files navigation

wanco 🐶

plot

wanco is a WebAssembly AOT compiler which supports cross-platform (CPU and OS) Checkpoint/Restore functionalities. wanco is forked from Wasker.

See examples for quick start.

Build

Prerequisites:

  • POSIX compliant OS (Linux, TODO: support macOS)
  • Cargo (Rust)

To install dependencies in Linux/Debian, run the following commands:

# Install LLVM 17
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
echo 'export LLVM_SYS_170_PREFIX="/usr/lib/llvm-17"' >> ~/.bashrc

# Install all other deps
sudo apt install build-essential cmake libpolly-17-dev libprotobuf-dev protobuf-compiler libunwind-dev libelf-dev libzstd-dev

First, clone the repository:

$ git clone [email protected]:tamaroning/wanco.git
$ cd wanco

To build the compiler and runtime, run the following commands:

$ mkdir build
$ cmake .. -DCMAKE_BUILD_TYPE=Release

# Install the compiler and the runtime libraries
$ sudo make install

Run

To compile the hello-world example, run:

$ wanco examples/hello.wat -o hello
$ ./hello
Hello World!

To show the help, run:

$ wanco --help

For debugging, run the compiler with RUST_LOG="debug" wanco <ARGS>.

Enable Checkpoint/Restore functionalities

Compile a WebAssembly file with C/R enabled and run it:

$ wanco --enable-cr demo/fib.wat
$ a.out

While the process is running, you can trigger checkpoint by sending SIGUSR1 signal (No.10) from another teminal:

(The running process is automatically terminated and the snapshot file is created.)

$ pkill -10 a.out

To restore the execution, run:

$ ./a.out --restore checkpoint.json

Note: Snapshot files are named checkpoint.json or checkpoint.pb.

Read the document if you are interested in how this works.

Compile and assemble only

If you want to see the compiled Wasm module, specify the -c option when running the compiler: LLVM assembly file (.ll) will be generated.

$ wanco examples/hello.wat -c -o hello.ll

After that, you can link it with the runtime library together by using clang

$ clang-17 -flto -no-pie hello.ll /usr/local/lib/libwanco_rt.a /usr/local/lib/libwanco_wasi.a -o hello

About

WebAssembly AOT compiler with cross-CPU checkpoint/restore support

Resources

License

Stars

Watchers

Forks

Packages

No packages published