Hi,
I'd like to understand if I should be investing time creating .wit or .witx definitions for my host functions for broad support. It seems like .witx is being deprecated in favour of .wit or is it the other way round?
I notice the snapshots of wasi function definitions in the official wasi repo use .witx for their definitions, are there any .wit definitions online I can use?
Additionally, where can I find code generation tools for both host & guest functions for the above formats? Is wit-bindgen best for .wit? I can't see any recommended .witx generators.
Thanks for the help in advance.
I also have the same question.
Witx is being deprecated, in favor of wit. The transition is in progress, and not everything is ready yet.
A wit-based version of WASI is in development; a prototype is here: https://github.com/bytecodealliance/preview2-prototyping/blob/main/wit/wasi.wit
wit-bindgen is the main tool family for working with wit files today, for both host and guest. It's usable, but under active development and not everything is stable yet.
Thanks for the feedback. In the wit specification ( https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md ) I don't see reference to "memory pointer" types (e.g. *mut [u8]). I assume we should use direct primitives to reference a pointer in the shared memory and that in the rust generator, we lose the pointer syntatic sugar. Is that correct? If so, what's an appropriate type for this? u32?
In wit interfaces, there is no shared linear memory. There are a few different alternatives, depending on your use case. Can you say more about what you'd do with an &mut [u8]
?
@Dan Gohman well for instance I'm trying to document some of wasmedge's host API's through WIT. Reviewing their guest Rust Sockets API, I can see what the expected types look like and try map those back to a wit definition. For example, how would I represent this WasmAddress struct in .wit might answer the question above? ( https://github.com/second-state/wasmedge_wasi_socket/blob/main/src/socket.rs#L52 )
wit isn't aiming to be able to describe existing APIs literally. It will be necessary to change how some things are done, when migrating to wit. For example, the wasi-sockets proposal passes socket addresses by value instead of by pointer: https://github.com/WebAssembly/wasi-sockets/blob/main/wasi-socket-ip.wit#L5
This has the advantage of avoiding the lifetime hazards of sharing pointers across interfaces.
Last updated: Nov 22 2024 at 16:03 UTC