Stream: general

Topic: Wizer: passing large memory block


view this post on Zulip Friday More (Dec 27 2024 at 20:43):

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?

view this post on Zulip Ramon Klass (Dec 27 2024 at 22:05):

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

view this post on Zulip Friday More (Dec 30 2024 at 17:28):

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).

view this post on Zulip fitzgen (he/him) (Dec 30 2024 at 22:11):

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.

view this post on Zulip Friday More (Jan 02 2025 at 18:09):

Got it, thanks!


Last updated: Jan 24 2025 at 00:11 UTC