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)
- CMake and C++ compiler
- Rust and Cargo
- LLVM 17
- Easiest way to install LLVM 17 is to use llvm.sh (Ubuntu/Debian)
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
chmod +x llvm.sh
./llvm.sh 17
- protocol buffer
- Run
apt install libprotobuf-dev protobuf-compiler
- Run
First clone the project:
$ git clone [email protected]:tamaroning/wanco.git
$ cd wanco
This project includes C++ projects and Rust projects. To build the entire project, run the following commands.
$ mkdir build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
To install the compilers and runtime libraries, run the following commands:
$ sudo make install
After building the project, you will find the wanco
binary in the top of build
directory.
Before compiling wasm modules, make sure to add clang to the PATH environment variable or to specify the path to clang or clang++ by using the --clang-path
option. (clang/clang++ version 17 or later is required.)
If --clang-path
is not set, clang-17
is used by default.
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>
.
Compile a WebAssembly file with C/R enabled and run it:
$ wanco --enable-cr --optimize-cr demo/fib.wat
$ a.out
While the process is running, you can trigger checkpoint by sending SIGUSR1
signal 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
(binary format generated with protobuf).
If you do not want a generated object file to be linked with runtime libraries, 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 -flto -no-pie hello.ll /usr/local/lib/libwanco_rt.a /usr/local/lib/libwanco_wasi.a -o hello
To test the compiler, run:
$ cargo test
docker buildx build .
- benchmark/: See LICENSE files in each directory
- others: MIT (See LICENSE)