Stream: general

Topic: wit vs witx


view this post on Zulip Daniel Blignaut (Jan 07 2023 at 18:45):

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.

view this post on Zulip Wilson Wang (Jan 07 2023 at 18:51):

I also have the same question.

view this post on Zulip Dan Gohman (Jan 07 2023 at 20:54):

Witx is being deprecated, in favor of wit. The transition is in progress, and not everything is ready yet.

view this post on Zulip Dan Gohman (Jan 07 2023 at 20:55):

A wit-based version of WASI is in development; a prototype is here: https://github.com/bytecodealliance/preview2-prototyping/blob/main/wit/wasi.wit

Polyfill adapter for preview1-using wasm modules to call preview2 functions. - preview2-prototyping/wasi.wit at main · bytecodealliance/preview2-prototyping

view this post on Zulip Dan Gohman (Jan 07 2023 at 20:58):

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.

view this post on Zulip Daniel Blignaut (Jan 08 2023 at 17:11):

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?

Repository for design and specification of the Component Model - component-model/WIT.md at main · WebAssembly/component-model

view this post on Zulip Dan Gohman (Jan 08 2023 at 17:30):

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]?

view this post on Zulip Daniel Blignaut (Jan 08 2023 at 17:39):

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

A Rust lib for socket on WasmEdge. Contribute to second-state/wasmedge_wasi_socket development by creating an account on GitHub.

view this post on Zulip Dan Gohman (Jan 08 2023 at 17:47):

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

WASI API proposal for managing sockets. Contribute to WebAssembly/wasi-sockets development by creating an account on GitHub.

view this post on Zulip Dan Gohman (Jan 08 2023 at 17:49):

This has the advantage of avoiding the lifetime hazards of sharing pointers across interfaces.


Last updated: Dec 23 2024 at 13:07 UTC