Skip to content

unknown ptrSize for $GOARCH "wasm" #40543

Closed
@Taoja

Description

@Taoja

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

randall77 commented on Aug 3, 2020

@randall77
Contributor

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

Taoja commented on Aug 3, 2020

@Taoja
Author

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

davecheney commented on Aug 3, 2020

@davecheney
Contributor

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.

locked and limited conversation to collaborators on Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @davecheney@randall77@gopherbot@Taoja

        Issue actions

          unknown ptrSize for $GOARCH "wasm" · Issue #40543 · golang/go