Stream: wasmtime

Topic: wasmtime-go components support


view this post on Zulip Alessandro Grassi (Mar 14 2025 at 14:45):

Hello everyone,
I've recently started exploring the world of WebAssembly, and I'm currently experimenting with Wasmtime in Go (wasmtime-go). I'm encountering some challenges understanding the current status of certain features and compatibility.

Specifically, I'd appreciate it if someone could clarify the following points:

  1. Is it currently possible to use WASM Components with the wasmtime-go bindings? I haven't found explicit documentation confirming support or limitations.
  2. My understanding is that WASI Preview 2 (aka WASI 2.0) isn't yet supported in wasmtime-go—is this correct?
  3. Actually, my goal isn't strictly tied to using a WASM Component. I'm primarily aiming to build a ping-server requiring network functionality. However, based on my current understanding, network functionalities aren't available in WASM modules / WASI Preview 1. Could someone confirm this?

Apologies if my questions seem unclear or lack detail; the available documentation left me uncertain.

Thanks in advance for your help!

view this post on Zulip Ralph (Mar 14 2025 at 16:24):

that's largely true but preview 2 is possible in go using tinygo; I don't know what the status of wasmtime-go is, however.

view this post on Zulip Joel Dice (Mar 14 2025 at 16:38):

Component (and thus WASIp2) support for wasmtime-go is blocked on https://github.com/bytecodealliance/wasmtime/pull/9812; likewise for any other Wasmtime embedding that uses the C API (e.g. wasmtime-dotnet). The one exception is wasmtime-py, which has its own, very limited support for components built in pure Python (insufficient for WASIp2, but works for simple components).

The goal is to be able to host wasm components in a wasmtime runtime embedded through the C api. This was discussed in issue #8036. Thanks to @rockwotj for the basis of the initial commit, in #7801...

view this post on Zulip Joel Dice (Mar 14 2025 at 16:39):

However, you might be interested in https://github.com/arcjet/gravity, which aims for component support in pure Go, based on Wazero.

Gravity is a host generator for WebAssembly Components. It currently targets Wazero, a zero dependency WebAssembly runtime for Go. - arcjet/gravity

view this post on Zulip Victor Adossi (Mar 17 2025 at 02:28):

As others have mentioned, TinyGo is the way to go for P2 components in Golang right now.

If you'll pardon the vendor-specific link, there's an example you can peek at for golang:
https://github.com/wasmCloud/go/tree/main/examples/component/http-server

HTTP stuff is abstracted away to wasihttp, but the go:generate calls in use there should be able to help.

The invoke example is a little bit simpler.

I'm not sure exactly what you mean by "ping server" (is the component doing the pings? is it actually ICMP or HTTP/S? etc), but network is supported currently in preview2, and in fact TLS support just landed in wasmtime main. The edges may be rough, but you should be able to make HTTP connections, raw socket connections, TLS connections and more from WASI p2 components at this point.

I think the question right now is just how many flags you'll need to add to wasmtime run/wasmtime serve, and what your WIT world should look like exactly :)

wasmCloud Go ecosystem libraries and tooling. Contribute to wasmCloud/go development by creating an account on GitHub.
wasmCloud Go ecosystem libraries and tooling. Contribute to wasmCloud/go development by creating an account on GitHub.
wasmCloud Go ecosystem libraries and tooling. Contribute to wasmCloud/go development by creating an account on GitHub.
fixes: #10089 This adds a crate that provides the Wasmtime host implementation for the wasi-tls API. The wasi-tls world allows WebAssembly modules to perform SSL/TLS operations, such as establishin...

view this post on Zulip Ralph (Mar 17 2025 at 10:39):

https://github.com/ydnar/wasi-http-go/issues/17#issuecomment-2728984527

tinygo version 0.36.0; Ubuntu 22.04. Git clone, make tools/make go-bindings, then squillace@idiopath:~/work/sample-wasi-http-go/wasi-http-go$ tinygo run -target=wasip2-http.json ./examples/basic # ...

view this post on Zulip Ralph (Mar 17 2025 at 10:39):

that repo will build directly, though you can see the messiness that yet still exists with p2. But it's possible.


Last updated: Apr 08 2025 at 19:03 UTC