Stream: wit-bindgen

Topic: Considering wit-bindgen as solution for rust+c+wasm project


view this post on Zulip Andrew Top (Jan 26 2023 at 22:03):

Hi there, we're considering depending on wit-bindgen at my project, and https://github.com/bytecodealliance/wit-bindgen suggested we reach out here first.

We have what looks to be a very well known problem: I'd like to build a wasm binary from rust code, but it contains C++ dependencies (built with the wasi-sdk clang toolchain). wasm-bindgen is effectively not an option in this case (right?), so wit-bindgen appears to be the main alternative.

And I love what I see with wit-bindgen, in fact I'd prefer its over wasm-bindgen, but it feels like it's in rapid development mode now and fairly
unstable (last release was v0.2.0 from August 2022).

So I had a couple questions,

1. v0.2.0 seems like it's not emitting any bindings for resource methods, is that feature known to be missing in v0.2.0?
2. Having support for callbacks in the interface is important for us, but I don't see that mentioned in the spec, am I missing something or is it just not spec'd yet?
3. Are there any known stable commits more recent than v0.2.0 I could use?
4. If wit-bindgen doesn't make sense for me, does anyone have any suggestions for building rust+c wasm packages?

Thanks!

A language binding generator for WebAssembly interface types - GitHub - bytecodealliance/wit-bindgen: A language binding generator for WebAssembly interface types
Repository for design and specification of the Component Model - component-model/WIT.md at main · WebAssembly/component-model

view this post on Zulip Toni Bofarull (Jan 26 2023 at 22:25):

The tests are failing while running cargo test --workspace (commit https://github.com/bytecodealliance/wit-bindgen/tree/98c2b1e4cb10d3757114b7524d112511a4c7459e) in the devcontainer. Any idea?

A language binding generator for WebAssembly interface types - GitHub - bytecodealliance/wit-bindgen at 98c2b1e4cb10d3757114b7524d112511a4c7459e

view this post on Zulip Mossaka (Joe) (Jan 27 2023 at 02:49):

  1. For your first question, yes. I believe the team is working on bringing resource back to wit.
  2. The callbacks are not in the spec of wit. This issue might be relevent https://github.com/bytecodealliance/wit-bindgen/issues/268.
  3. I am not aware of any stable commits after v0.2.0. wit-bindgen is undergoing a huge change to adapt to the wasm component model.
This is a follow-up question regarding why wit-bindgen does not generate host trait with access to Store<T>. @alexcrichton explained in a Zulip chat: the wit-bindgen-generated bindings don&#3...

view this post on Zulip Andrew Top (Jan 27 2023 at 18:44):

Thanks!

It sounds like it's going to be a bit of a rollercoaster ride while the wasm component model changes are happening, so I'll leave trunk alone.

Maybe I can make v0.2 work for me. Feels like this is almost the only option for creating wasm bindings for Rust when it's compiled under wasm32-wasi.

view this post on Zulip Lann Martin (Jan 27 2023 at 18:56):

You can take a look at https://github.com/fermyon/wit-bindgen-backport as an example of backporting dependency updates to v0.2. That repo in particular has no stability guarantees though so you may want to fork it if its useful to you.

A language binding generator for WebAssembly interface types - GitHub - fermyon/wit-bindgen-backport: A language binding generator for WebAssembly interface types

view this post on Zulip Andrew Top (Jan 27 2023 at 19:53):

Ahh, thanks, good to know.

Is there a list of projects that are depending on wit-bindgen (either v0.2 or otherwise) that I might use as reference?

view this post on Zulip Lann Martin (Jan 27 2023 at 19:55):

Not that I'm aware of. Sourcegraph or github search are probably your best bet for that.


Last updated: Dec 23 2024 at 12:05 UTC