Stream: wasmtime

Topic: Overriding snapshot preview 1 implementation


view this post on Zulip Roman Volosatovs (Mar 07 2022 at 16:02):

Is there any functionality provided that allows overriding snapshot preview 1 implementation?
I see that the implementation is provided for WasiCtx https://github.com/bytecodealliance/wasmtime/blob/8c9c72caaac6f7a21f031f274c87eb26ac630ca7/crates/wasi-common/src/snapshots/preview_1.rs#L194-L1182

Obvious approach with wrapping WasiCtx into a custom struct implementing the trait and using that context instead does not seem to work, in particular because add_to_linker expects a getter returning a WasiCtx struct https://github.com/bytecodealliance/wasmtime/blob/7a1b7cdf92a644a256a9f4c5c002682e1900d817/crates/wasi/src/lib.rs#L47

linker.func_wrap("wasi_snapshot_preview1"... approach seems to break the runtime, but I have to explore this option more.

Regardless, it would be beneficial to have an implementable trait here.
Would refactoring add_to_linker closure signature return type to use a trait instead be an acceptable way forward?

Any suggestions, ideas?

Standalone JIT-style runtime for WebAssembly, using Cranelift - wasmtime/preview_1.rs at 8c9c72caaac6f7a21f031f274c87eb26ac630ca7 · bytecodealliance/wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift - wasmtime/lib.rs at 7a1b7cdf92a644a256a9f4c5c002682e1900d817 · bytecodealliance/wasmtime

view this post on Zulip Roman Volosatovs (Mar 07 2022 at 18:32):

Filed https://github.com/bytecodealliance/wasmtime/pull/3895

In some use cases it is desirable to provide a custom snapshot WASI context. Facilitate this by depending on a combination of traits required rather than concrete type in the signature. This change...

Last updated: Oct 23 2024 at 20:03 UTC