bytecodealliance / bytecodealliance/wasmtime-go

undefined: wasmtime.Wat2Wasm on windows and macos (darwin)

Open
#240 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
913
Forks
100
Avg merge
10m
Merged PRs (30d)
1

Description

When compiling with GOOS and GOARCH flags, compilation fails when GOOS is windows or darwin, but succeeds when it is linux.
I am running the `go build` command from linux (tried both fedora-41 locally and ubuntu-latest through build pipeline).

## Issue

Running:
`GOOS=windows GOARCH=amd64 go build -o test`
`GOOS=darwin GOARCH=amd64 go build -o test`

Produces:
`undefined: wasmtime.Wat2Wasm`

### Conditions

In the file it complains about, there is an import `"github.com/bytecodealliance/wasmtime-go/v29"` and a function call `wasmBytes, err := wasmtime.Wat2Wasm(wat)`.

## Not an issue

Running:
`GOOS=linux GOARCH=amd64 go build -o test`

Works fine without any compilation error.

---

Seems very strange to me that GOOS would affect something becoming undefined, so I'm suspecting something might be wrong? If there is an explanation for this or I am missing something, then perhaps it would be good to add that to the readme file. If I am the only one with this issue, do let me know.

### Workaround (In case someone else has this issue)

I managed to work around it by not cross-compiling and adding flag `CGO_ENABLED=1`. That made it work of macos.
For windows I also needed to download MinGW and set `CC=x86_64-w64-mingw32-gcc` and `CXX=x86_64-w64-mingw32-g++`

Leaving that here in case it helps anybody else.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.