Skip to content

Latest commit

 

History

History
98 lines (79 loc) · 1.51 KB

README.md

File metadata and controls

98 lines (79 loc) · 1.51 KB

lang2

Compile source code

cargo run example/a
./build/main.out

Run REPL

cargo run

Install

LLVM, MLIR

https://apt.llvm.org/

bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" -- 19
sudo apt install libzstd-dev libpolly-19-dev libmlir-19-dev
export MLIR_SYS_190_PREFIX=/usr/lib/llvm-19
export TABLEGEN_190_PREFIX=/usr/lib/llvm-19
export LLVM_SYS_180_PREFIX=/usr/lib/llvm-19  # for inkwell

wasmtime

curl https://wasmtime.dev/install.sh -sSf | bash

run .wasm

wasmtime run build/main.wasm

wasm-tools

cargo install wasm-tools

wasm -> wat

wasm-tools print build/main.wasm -o a.wat

wat -> wasm

wasm-tools parse a.wat -o a.wasm

cargo-component

A cargo extension for authoring WebAssembly components

cargo install cargo-component

wasi-sdk

https://github.com/WebAssembly/wasi-sdk/releases

mkdir misc
cd misc
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz
tar xvf wasi-sdk-24.0-x86_64-linux.tar.gz
cd ..
export WASI_SDK_PATH=./misc/wasi-sdk-24.0-x86_64-linux

Test

cargo test -- --test-threads=1
cargo test backend::llvm::inkwell_example::hello_world -- --nocapture

Docker

Development

docker build . -t lang2-dev --target dev
docker run --rm -it -v .:/mnt lang2-dev

Run test

docker build . -t lang2 --target test

REPL

docker build . -t lang2 --target run
docker run --rm -it lang2