Locally Compiling Your Algorithm into WASM
To compile your algorithm into WASM, you will use the tig-wasm
Rust crate for wrapping algorithm submissions for compilation into WASM with an exported entry_point
.
Compiling Algorithm into WASM with entry-point
These steps replicate what TIG’s Github Action CI does (.github/workflows/build_algorithm.yml
):
- Set environment variables to match the algorithm you are compiling:
export CHALLENGE=<challenge_name>
export ALGORITHM=<algorithm_name>
- Compile your algorithm
cargo build -p tig-wasm --target wasm32-wasi --release --features entry-point
- Optimise the WASM and save it into
tig-algorithms/wasm
:
mkdir -p tig-algorithms/wasm/${CHALLENGE}
wasm-opt target/wasm32-wasi/release/tig_wasm.wasm -o tig-algorithms/wasm/${CHALLENGE}/${ALGORITHM}.wasm -O2 --remove-imports