Skip to content

fix: add empty.s to fix compilation error#6

Merged
asteurer merged 1 commit into
bytecodealliance:mainfrom
jamesstocktonj1:feat/testable-go
Mar 5, 2026
Merged

fix: add empty.s to fix compilation error#6
asteurer merged 1 commit into
bytecodealliance:mainfrom
jamesstocktonj1:feat/testable-go

Conversation

@jamesstocktonj1
Copy link
Copy Markdown
Contributor

Description

When attempting to run unit tests whilst importing the go.bytecodealliance.org/pkg/wit/types package I get the following compilation error:

$ go test ./...
# go.bytecodealliance.org/pkg/wit/async
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:221:6: missing function body
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:224:6: missing function body
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:227:6: missing function body
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:230:6: missing function body
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:233:6: missing function body
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:236:6: missing function body
.../go.bytecodealliance.org/pkg@v0.2.0/wit/async/async.go:239:6: missing function body
FAIL    <go module> [build failed]
FAIL

wit-bindgen-go got round this issue by including a blank empty.s assembly file within each of the directories which includes a Go file that uses the //go:wasmimport directive. See here for example.

This tricks the Go compile into thinking there is an assembly implementation of the function which has been declared, and so it no longer complains about the missing function body.

After adding the following changes, unit tests run successfully without build error.

See more

Copy link
Copy Markdown
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jamesstocktonj1!

@asteurer any concerns about this?

@asteurer asteurer merged commit ee1c3b6 into bytecodealliance:main Mar 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants