Enum WasmCallingConvention
WebAssembly calling conventions.
public enum WasmCallingConvention
Fields
ClangWasi = 3Clang-specific calling convention that works with modules built using
--target=wasm32-wasi.To build a compatible module:
- Install LLVM packages for WASM:
wasi-libc libc++abi-dev-wasm32 libc++-dev-wasm32 libclang-rt-dev-wasm32. - Build and link the module with
clang --target=wasm32-wasi --no-standard-libraries -nostartfiles -Wl,--no-entry -Wl,--export-all -fvisibility=hidden. - Use the generated
.wasmfile as the compute module.
- Install LLVM packages for WASM:
Generic = 0Generic calling convention. Aims to be language-agnostic.
- Calls
_startand/or__wasm_call_ctorsfor module initialization (if present). - Requires
allocanddeallocexports for memory management.
- Calls
GenericCommand = 4Generic command calling convention. Unlike "reactor" conventions which require an exported function to call ("library" mode), here we run the module as a command (program), passing the job argument to standard input and reading the result from the standard output.
NOTE: Only string arguments and results are supported in this mode.
For example, a Python program reading
sys.stdinand writing to standard output, compiled withpy2wasm --output hello.wasm hello.py, can be used as the compute module. Use CreateCommand<TArg>(string, IEnumerable<DeploymentUnit>?, JobExecutionOptions?, IMarshaller<TArg>?, IMarshaller<string>?) to create the job descriptor.GoWasiReactor = 2Go-specific calling convention that works with modules built using
GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared.To build a compatible module:
- In Go code, use
//go:wasmexportto mark functions for export. - Build the module:
GOOS=wasip1 GOARCH=wasm go build -o addone.wasm -buildmode=c-shared. - Use the generated
addone.wasmfile as the compute module.
- In Go code, use
RustWasmBindgen = 1Rust-specific calling convention that works with modules built using
wasm-packandwasm-bindgen.To build a compatible module:
cargo install wasm-packcargo new --lib hello-wasm- Add
crate-type = ["cdylib"]and awasm-bindgendependency toCargo.toml. - Export functions in
src/lib.rswith the#[wasm_bindgen]attribute. - Build the module:
wasm-pack build. - Use the generated
pkg/hello_wasm_bg.wasmfile as the compute module.