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.
Prerequisites:
- POSIX compliant OS (Linux, TODO: support macOS)
- Cargo (Rust)
- Install from the website
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-devFirst, clone the repository:
$ git clone [email protected]:tamaroning/wanco.git
$ cd wancoTo 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 installTo compile the hello-world example, run:
$ wanco examples/hello.wat -o hello
$ ./hello
Hello World!To show the help, run:
$ wanco --helpFor debugging, run the compiler with RUST_LOG="debug" wanco <ARGS>.
Compile a WebAssembly file with C/R enabled and run it:
$ wanco --enable-cr demo/fib.wat
$ a.outWhile 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.outTo restore the execution, run:
$ ./a.out --restore checkpoint.jsonNote: Snapshot files are named checkpoint.json or checkpoint.pb.
Read the document if you are interested in how this works.
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.llAfter 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
