go:wasmexport: unsupported parameter type

Open
#185 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
go, wasm

Research direction

Start with the supported and unsupported parameter-type test linked in Go change 611315, then review the wasmexport signatures shown in this issue. Validate any proposed direction through the reactor host setup and a call to the exported function; done means the affected bindings can use the needed parameter types successfully.

Written by the indexing model from the issue text.

Description

Work is being done in Go 1.24 to support go:wasmexport.

However, there are a handful of unsupported parameter types. The following test shows the supported and unsupported types https://go-review.googlesource.com/c/go/+/611315

*string, and *uint8 are examples I have run into with the current wit-bindgen-go bindings.

Is it a possible solution to use unsafe.Pointer and convert the parameters to their necessary types?

I.e

Breaking

//go:wasmexport count
//export count
func wasmexport_Count(s0 *uint8, s1 uint32, sub0 *uint8, sub1 uint32) (result0 uint32) {
	s := cm.LiftString[string]((*uint8)(s0), (uint32)(s1))
	sub := cm.LiftString[string]((*uint8)(sub0), (uint32)(sub1))
	result := Exports.Count(s, sub)
	result0 = (uint32)(result)
	return
}

Possible workaround

//go:wasmexport count
//export count
func wasmexport_Count(s0 unsafe.Pointer, s1 uint32, sub0 unsafe.Pointer, sub1 uint32) (result0 uint32) {
	s := cm.LiftString[string]((*uint8)(s0), (uint32)(s1))
	sub := cm.LiftString[string]((*uint8)(sub0), (uint32)(sub1))
	result := Exports.Count(s, sub)
	result0 = (uint32)(result)
	return
}

I am still working through a test to ensure this functionality works. I am currently working through the reactor host setup to call the exported function.

Dominant language
Go
Stars
148
Forks
20
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bytecodealliance/go-modules

All issues in bytecodealliance/go-modules

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.