$ wasmtime --invoke fibzig fibzig.wasm 16
Error: failed to run main module `fibzig.wasm`
Caused by:
0: failed to instantiate "fibzig.wasm"
1: unknown import: `env::__linear_memory` has not been defined
When I disassemble the Wasm file with wasm2wat I can see the import, but it seems to me that the module does not not use it. So the import seems to be useless. How can I suppress the import of env::__linear_memory?
The first thing to note is that Zig builds wasm binaries with zig build-exe. Since you are not creating a shared lib but rather a regular wasm module, you will want to use that subcommand. Something like the following should work:
The -fno-entry says that there is no main function or _start symbol to load. -rdynamic means that any public exports will be added to the output, otherwise you would likely get an empty module. If you want to be more specific, you can use --export=fibzig
You may also want to add -OReleaseSmall when you eventually do get to where you want to distribute this so that the module is smaller.
If you wanted to do it with the zig build system, you would do the following: