Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Mewz-project/Wasker
Wasm compiler for running Wasm on your favorite kernel
https://github.com/Mewz-project/Wasker
compiler llvm rust wasm webassembly
Last synced: 29 days ago
JSON representation
Wasm compiler for running Wasm on your favorite kernel
- Host: GitHub
- URL: https://github.com/Mewz-project/Wasker
- Owner: mewz-project
- License: other
- Created: 2023-12-28T05:38:49.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-03-26T08:02:50.000Z (4 months ago)
- Last Synced: 2024-04-17T00:11:28.356Z (3 months ago)
- Topics: compiler, llvm, rust, wasm, webassembly
- Language: WebAssembly
- Homepage:
- Size: 1.07 MB
- Stars: 237
- Watchers: 3
- Forks: 12
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-stars - Mewz-project/Wasker - Wasm compiler for running Wasm on your favorite kernel (WebAssembly)
README
![Wasker_logo](./doc/assets/wasker.png "Wasker_logo")
# Wasker
Wasker is a WebAssembly compiler.
Wasker compiles Wasm binary into ELF format binary.
Currently, Wasker supports WASI preview 1.![Wasker_architecture](./doc/assets/wasker_architecture.png "Wasker_architecture")
## What's new with Wasker
There are already software tools that compile Wasm to native binaries.
What's new with Wasker is, Wasker generates an **OS-independent** ELF file where WASI calls from Wasm applications remain **unresolved**.
This unresolved feature allows Wasker's output ELF file to be **linked with WASI implementations provided by various operating systems**, enabling each OS to execute Wasm applications.
Wasker empowers your favorite OS to serve as a Wasm runtime!
# How to run Wasker
Wasker compiler is based on LLVM (LLVM 15 currently).![demo](./doc/assets/wasker.gif)
## Option1 : Use Docker
Clone repository
```
git clone [email protected]:Mewz-project/Wasker.git
cd Wasker
```Create directory for mount and place input Wasm/WAT file.
Please refer [examples](./examples) for building Wasm from Rust and Go.
Here, as an example, we'll use the already built `helloworld.wat` included in this repository.
```
mkdir -p mount
mv helloworld.wat mount
```Run Wasker via docker (It may take few minuits to pull image, so you can build image locally by `docker build -t wasker .`)
ELF file will be generated under `mount` directory as `wasm.o`.
```
docker run -it --rm -v $PWD/mount:/work/mount -t ghcr.io/mewz-project/wasker:latest mount/helloworld.wat
[2023-12-28T09:20:27Z INFO wasker::compiler] input: mount/helloworld.wat
[2023-12-28T09:20:27Z INFO wasker::compiler] write to wasm.ll
[2023-12-28T09:20:27Z INFO wasker::compiler] write to wasm.o, it may take a while
[2023-12-28T09:20:28Z INFO wasker::compiler] Compile success
```## Option2 : Use Devcontainer
You can try Wasker on browser via Devcontainer.Start Devcontainer
- Click `Code` -> `Codespaces` -> `New codespace` on this repository page.
- Wait for a while, then you can see VSCode on browser.
- Open terminal on VSCodeRun Wasker
```
cargo run helloworld.wat
```## Option3 : Build from source
### Clone repository
```
git clone [email protected]:mewz-project/wasker.git
cd Wasker
```### Install LLVM locally
The commands are a little different because you need an LLVM binary built for your architecture.
#### AMD64
```
mkdir -p dependencies/llvm
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang+llvm-15.0.0-x86_64-linux-gnu-rhel-8.4.tar.xz -O /tmp/llvm-15.0.0.tar.xz
tar -xvf /tmp/llvm-15.0.0.tar.xz -C dependencies/llvm
export LLVM_SYS_150_PREFIX=$PWD/dependencies/llvm/clang+llvm-15.0.0-x86_64-linux-gnu-rhel-8.4
```#### AArch64
```
mkdir -p dependencies/llvm
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang+llvm-15.0.0-aarch64-linux-gnu.tar.xz -O /tmp/llvm-15.0.0.tar.xz
tar -xvf /tmp/llvm-15.0.0.tar.xz -C dependencies/llvm
export LLVM_SYS_150_PREFIX=$PWD/dependencies/llvm/clang+llvm-15.0.0-aarch64-linux-gnu
```### Run Wasker
```
cargo run helloworld.wat
```# How to use Wasker outputs
ELF file generated by Wasker is OS-independent: WASI calls from Wasm applications remain unresolved.
Please write your own WASI wrapper for your favorite OS to be linked with Wasker output.
Here, we'll show a [tiny example](./examples/wasi-wrapper/wasi-wrapper-linux.c) of running Wasker output on Linux.
Link Wasker output and WASI wapper for Linux
```
gcc -no-pie ./examples/wasi-wrapper/wasi-wrapper-linux.c ./wasm.o -o hello
```Run!!
```
./hello
```Also please check [Mewz](https://github.com/Mewz-project/Mewz.git), a unikernel OS which has WASI interface.
ELF file generated by Wasker can be executed on Mewz without any modification.