Skip to content
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

unknown ptrSize for $GOARCH "wasm" #40543

Closed
Taoja opened this issue Aug 3, 2020 · 3 comments
Closed

unknown ptrSize for $GOARCH "wasm" #40543

Taoja opened this issue Aug 3, 2020 · 3 comments

Comments

@Taoja
Copy link

@Taoja Taoja commented Aug 3, 2020

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"
@randall77
Copy link
Contributor

@randall77 randall77 commented 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
Copy link
Author

@Taoja Taoja commented 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.

is cgo will support for wasm in future?

@davecheney
Copy link
Contributor

@davecheney davecheney commented Aug 3, 2020

is cgo will support for wasm in future?

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.

@davecheney davecheney closed this Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.