Rust bindings for Faasm. At the moment an experimental POC.
- Faasm libs at traditional locations (
/usr/local/faasm/llvm-sysroot/lib/
) codegen_func
andsimple_runner
compiled on Faasm branchmfournial:add-rust
and in thePATH
.- Recent Rust compiler installed via
rustup
, prefer nightly. - The Wasm target of interest Rust libraries installed:
rustup target add wasm32-unknown-unknown [--toolchain nightly]
There is 2 others targets for Wasm (wasm32-wasi
, wasm32-unknown-emscripten
) that might be useful
in the future.
Building the Wasm binary is done with cargo.
Cargo's build directory is called target
. target
directory is
directed one level up, which
cargo build --target wasm32-unknown-unknown
NAME=simple_link
INSTALL_DIR=/usr/local/code/faasm/wasm/rust/$NAME
mkdir -p $INSTALL_DIR
# Depending on whether we are in the Rust-Faasm workspace or not
if [ -d target ]
then
cp target/wasm32-unknown-unknown/debug/faasm-sys.wasm $INSTALL_DIR/function.wasm
else
cp ../target/wasm32-unknown-unknown/debug/faasm-sys.wasm $INSTALL_DIR/function.wasm
fi
# Faasm toolchain as usual, could use inv too
codegen_func rust $NAME
simple_runner rust $NAME
Although panics do not look pretty when they happen in Wasm, main
uses the assert_eq
macro for
example to check the value of an expression.
assert_eq!(omp::get_num_threads(), 1);