Stream: wit-bindgen

Topic: ✔ tinygo bindings do not have a Drop() on resources now


view this post on Zulip Daniel Vigovszky (Feb 01 2024 at 14:25):

Hello! I'm upgrading everything to the latest, final preview2 version, and in that process I noticed that the latest (0.16.0) version of wit-bindgen no longer generates proper Drop functions for the resource types.

I have a test component that uses wasi-http bindings from go (basically a test built around this: https://github.com/golemcloud/go-wasi-http). With 0.14.0 this roundtrip.go file compiled and worked correctly. With the latest version it fails because all the .Drop() calls are now undefined.

If I check the generated C and go files, I see that in the C files we have the necessary functions, for example:

__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]output-stream")))
extern void __wasm_import_wasi_io_0_2_0_streams_output_stream_drop(int32_t handle);

void wasi_io_0_2_0_streams_output_stream_drop_own(wasi_io_0_2_0_streams_own_output_stream_t handle) {
  __wasm_import_wasi_io_0_2_0_streams_output_stream_drop(handle.__handle);
}

but there is no corresponding `Drop()` function for `WasiIo0_2_0_StreamsOutputStream` in the generated Go file.

void wasi_io_0_2_0_streams_output_stream_drop_borrow(wasi_io_0_2_0_streams_own_output_stream_t handle) {
  __wasm_import_wasi_io_0_2_0_streams_output_stream_drop(handle.__handle);
}
WASI HTTP RoundTrip implementation for Go net/http - GitHub - golemcloud/go-wasi-http: WASI HTTP RoundTrip implementation for Go net/http

view this post on Zulip Daniel Vigovszky (Feb 01 2024 at 14:29):

I was trying to find what change could cause it between 0.14.0 and 0.16.0, but could not find it yet. Also I've found that there are test cases that expect a Drop function to be generated so I'm not sure what's going on.

view this post on Zulip Daniel Vigovszky (Feb 01 2024 at 14:33):

Sorry, I was not exactly precise with saying it worked well with 0.14.0 - in fact it was tested with 3433f2d8515dd9eba95fd3ad581f5c389ae9dd1f which is newer.

view this post on Zulip Daniel Vigovszky (Feb 01 2024 at 14:41):

image.png

diff between using latest wit-bindgen@0.16.0 with WITs from wasmtime 17 vs wit-bindgen@3433f2 with WITs from wasmtime 15

view this post on Zulip Daniel Vigovszky (Feb 01 2024 at 14:49):

Ah never mind. I just realized that 0.16.0 is an older release from December :man_facepalming:

view this post on Zulip Daniel Vigovszky (Feb 01 2024 at 14:49):

Got confused by all the different versions of all the components and tools. sorry.

view this post on Zulip Notification Bot (Feb 01 2024 at 14:50):

Daniel Vigovszky has marked this topic as resolved.

view this post on Zulip Ralph (Feb 01 2024 at 17:18):

not at all! in nov and dec the wit versions and impls were flying fast and furious....

view this post on Zulip Mossaka (Joe) (Feb 03 2024 at 00:47):

Oh hey, yeah I added the Drop() functions after the latest release version. We need to get a new release.

Ping @Alex Crichton

view this post on Zulip Alex Crichton (Feb 05 2024 at 17:51):

Sure yeah, I posted https://github.com/bytecodealliance/wit-bindgen/pull/830 for that

A language binding generator for WebAssembly interface types - Bump crates to 0.17.0 by alexcrichton · Pull Request #830 · bytecodealliance/wit-bindgen

Last updated: Dec 23 2024 at 12:05 UTC