Hi after compiling a hello world program, I am left with a cwasm file - which I am assuming is a bytecode binary format.
Is it possible for me to get an executable binary out of wasmtime?
which I am assuming is a bytecode binary format.
It is file containing native code.
Is it possible for me to get an executable binary out of wasmtime?
Wasm needs a runtime. If you want you can use wasmtime as library in a regular non-wasm executable and use include_bytes!()
to include the .cwasm
file in the binary. You can disable the cranelift feature of wasmtime as there is no need to compile anything. This will make the executable smaller and save compile time.
Thanks @bjorn3
not sure i grasped the process. there any sample code/example that I can read through on how to do this?
Assuming you want to use wasi you can use the following example as starter: https://github.com/bytecodealliance/wasmtime/blob/main/examples/wasi/main.rs I think you only need to replace the Module::from_file(...)?
call with Module::deserialize(&engine, include_bytes!("the_precompiled_wasm_module.cwasm"))?
.
Thank you!
Last updated: Nov 22 2024 at 17:03 UTC