Stream: wasmtime

Topic: use component model to expose wasmtime embedding API


view this post on Zulip Pavel Šavara (Jul 22 2025 at 08:38):

There is long standing gap in wasmtime C API for working with WASIp2 guests. I think this is because core team mostly works with Rust.

If I wanted to use WASIp2 features of wasmtime while embedding inside of dotnet I'm depended on those features to be exposed as C API first and then I need to build C# projection.

But we already have great language independent IDL, WIT+component model. So I realized that we could use wit-bingen to expose the wasmtime embedding APIs and consume it it C# by wit-bindgen. Instead of hop thru C language.

@Christof Petig told me last year that he is using component model for interop between different languages of the same process and address space.

I don't know if maintaining embedding WIT is easier than finishing the C embedding API. But doing it in WIT would make consumption language independent. And the new features of the embedding API would be available in any language at the same time.

Feature Expose the component model in the C API for other languages than Rust. Benefit Components in all the languages! (on the host side) Implementation I have a POC I created here with some feedb...
Context https://github.com/bytecodealliance/wasmtime/tree/main/examples/component Add support for making the same example from C#. https://github.com/WebAssembly/component-model/tree/main https://g...

view this post on Zulip Alex Crichton (Jul 22 2025 at 14:10):

There's actually been some steady progress from a contributor MangoPeachGrape in adding C API support to the component model. It's not based on WIT but I've long wanted to have an option for something based on WIT. Basically the exact ABI for more efficient function calls I think is still an open question where WIT provides a nice answer

view this post on Zulip Christof Petig (Jul 28 2025 at 20:57):

Sorry, this thread simply got scrolled past on my side.

Indeed I have been completing a design for WIT between native shared objects which eliminates most copies (eliminating all require an API change).

I call this symmetric mode, https://github.com/cpetig/wit-bindgen/tree/work-in-progress has the most recent version of it. Currently I also have streams and futures working in C++ and Rust, async calls are on the implementation list for "tonight".

If you want a sneak peek simply run the normal WIT runtime tests (including a few of the async) with --symmetric and watch them compile for and run on native. Not everything is perfect but most is working fine.

I would like to add a hash (of the binary WIT subset) to the function to cause linker error on the slightest chance of incompatible changes to arguments and results - and also work on a zero-copy publisher (multiple) subscriber extension which is compatible between native and wasm (see https://github.com/WebAssembly/component-model/issues/398#issuecomment-3116844798 )

A (C++) language binding generator for WebAssembly interface types - GitHub - cpetig/wit-bindgen at work-in-progress
This all started with defining zero copy shared memory over a WIT interface (channel is WIT resource, inspired by iceoryx2): let channel = Channel_u32::new("topic"); loop { let message = channel.al...

view this post on Zulip Christof Petig (Jul 28 2025 at 21:01):

PS: While there is a draft merge request on wit-bindgen https://github.com/bytecodealliance/wit-bindgen/pull/1098 I tend to stall pushing to that branch to minimize CI load.

My fork has aggregated several potentially separable parts over the past years. I would like to come up with a plan to incrementally merge in interest order, so I would love to get feed-back about ...

view this post on Zulip Ralph (Jul 29 2025 at 12:05):

@Christof Petig you're not going to be at OSS Summit EU by any chance, are you?

view this post on Zulip Christof Petig (Jul 29 2025 at 16:19):

I didn't plan for it, but it looks very interesting.


Last updated: Dec 06 2025 at 06:05 UTC