-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go: switch CGo implementation to component model canonical ABI in pure Go implementation #614
Comments
Just found out that TinyGo has In addition, TinyGo 0.28.0 supports This technically unblocks me from removing CGO and C bindings dependency on the wit-bindgen-go generator. |
I am happy to be able to implement a simple Go binding for the following WIT file without using CGo and C bindings! // wit/host.wit
package example:host
world host {
import print: func(msg: string)
export run: func()
} The Go binding code looks like package host
import "unsafe"
//go:wasmimport $root print
func hostPrint(ptr0, len0 int32)
func HostPrint(msg string) {
hostPrint(*(*int32)(unsafe.Pointer(&msg)), int32(len(msg)))
}
// Export functions from host
var host Host = nil
func SetHost(i Host) {
host = i
}
type Host interface {
Run()
}
//go:export run
func HostRun() {
host.Run()
} The Go runtime I used is To see the full repo, please refer to here. |
Is this going through the Canon lift and Canon lower functions of the component abi injected by one of the wasm tools (or tinygo) or is it just passing an array of bytes through the wasm export, import? |
I have problems using TinyGo. For some unknown reason the code does not work as expected. And it's impossible to debug because tinygo doesn't even support What's blocking from moving to the standard GC compiler right now? Can I help somehow? |
We are working towards this goal, but there are several milestones we need to reach before moving to the "big Go" compiler. |
This is really excellent, I want it! Is there someplace with any work in progress? How can I help? |
Check out @ydnar work on Also, if you are interested, we have biweekly BytecodeAlliance Go subgroup meeting to discuss these topics! Check out agenda list! |
I'd like to change the implementation of the go-bindgen from using CGO and depending on the C bindings to using the canonical ABI implementation.
The biggest block, however, is there is no mechanism to export functions to Wasm. I know that
//go:wasmimport
will land in Go 1.21 (Augest release), and//go:wasmexport
is planned and might have developed. Once these two are available, I think we will be able to re-write the go-bindgen using canonical ABI.The text was updated successfully, but these errors were encountered: