We have a Wasm module which needs a large memory block which is used for initialization. The only way I can think of for passing it is by using Wasi (e.g. a file). However, we need a way to also provide a host function to the module, for which I used a custom linker. From the docs, it seems using Wasi and a custom linker are mutually exclusive. Is there a way forward for me?
you can add the std wasi0.2 wasi-* interfaces to your custom linker, what you are quoting reminds me of a line in the wizer readme, but they just mean "if you use a custom linker and wasi together, make sure to add wasi-* interfaces to it" with that
Thanks, this is helpful! A somewhat related follow up: if we make wasi access available for the Wizer initialize method, can we make it unavailable for other methods of the snapshotted module? I notice there is a keep_init_func
method to remove the initialize method, but can we do the same for imports used by the initialize functions (specifically those that need wasi).
there is no method to automatically remove wasi imports, but such a feature would be a welcome PR
or you can use something like wasmtime -W unknown-imports-trap=y path/to/module.wasm
which will stub out any imports that don't exist with functions that just trap if they are actually called. you can also do the moral equivalent of that with component linking/virtualization or binary rewriting.
Got it, thanks!
Last updated: Jan 24 2025 at 00:11 UTC