bytecodealliance/wit-bindgen

Go: TinyGo 0.3.3 wasp2 compiler target does not work with wit-bindgen-go v0.30.0

Opened this issue · 1 comments

siris commented

TinyGo 0.3.3 was released on August 20, 2024 and adds support for WASI preview 2 compilations via its new wasip2 compiler target.

I am currently using wit-bindgen to run Go Wasm compiled by TinyGo to the wasi target to then run on-top of Wasmtime. Everything works fine with the latest wit-bindgen-cli crate v0.30.0 and the wasi TinyGo target. But when testing the new wasip2 from TinyGo 0.3.3 using this command:

tinygo build -target wasip2 -no-debug -opt s -o helloworld.wasm helloworld.go

This is the compilation error I am seeing:

# github.com/REDACTED/go-REDACTED
../../../../go/pkg/mod/github.com/!REDACTED/go-REDACTED@v0.0.3-0.20240820194840-28111e2c617b/REDACTED.go:4:13: note: in file included from REDACTED.go!cgo.c:2:
../../../../go/pkg/mod/github.com/!REDACTED/go-REDACTED@v0.0.3-0.20240820194840-28111e2c617b/REDACTED.go:5:13: fatal: 'stdlib.h' file not found
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:12:11: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:13:3: error: unknown type name 'size_t'
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:13:10: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:19:14: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:20:3: error: unknown type name 'size_t'
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:20:10: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:24:21: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:25:21: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:29:38: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:30:3: error: unknown type name 'size_t'
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:30:10: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:34:8: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:35:30: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:39:39: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:40:35: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:41:28: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:57:34: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:58:31: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:59:35: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:60:28: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:82:8: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:84:48: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:85:45: expected a bitfield
../../../../go/pkg/mod/github.com/!REDACTED/REDACTED.h:86:5: expected a bitfield

Does something need to be changed in wit-bindgen to support the new TinyGo wasip2 target?

Thanks for raising this issue. Have you checked out this repo, https://github.com/ydnar/wasm-tools-go by @ydnar? It implements the wit bindings in pure Go instead of CGo and we are transitioning to replace wit-bindgen-go in this repo with it.