Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.14.6 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/huangwutao/Library/Caches/go-build" GOENV="/Users/huangwutao/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/huangwutao/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y4/5jgjdbn12rg03j1__vf0mg340000gn/T/go-build891741688=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
i trying build a wasm file:
$ GOOS=js GOARCH=wasm go build -o lib.wasm test.go
and test.go source code is :
package main import "C" import ( "syscall/js" ) func main() { var window = js.Global() var cb = js.FuncOf(func(this js.Value, args []js.Value) interface{} { return args[0].Int() + args[1].Int() }) window.Set("test", cb) select {} }
What did you expect to see?
got a wasm file
What did you see instead?
# runtime/cgo unknown ptrSize for $GOARCH "wasm"
Activity
randall77 commentedon Aug 3, 2020
cgo is not supported for wasm. The error could be clearer, though.
Remove the
import "C"
. You're not using it, and that should fix the problem.Taoja commentedon Aug 3, 2020
is cgo will support for wasm in future?
davecheney commentedon Aug 3, 2020
very unlikely as you would need a C to wasm compiler for you C dependencies.
I'm going to close this question as answered based on the answer from @randall77 above.