ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

gccgo error: unsafeZeroArr is not a function #339

Closed peterlabuschagne closed 4 years ago

peterlabuschagne commented 4 years ago

I get this error when trying to compile

github.com/ugorji/go/codec

../../../go/pkg/mod/github.com/ugorji/go/codec@v1.1.13/helper_unsafe.go:904:3: error: unsafeZeroArr is not a function; //go:linkname is only supported for functions 904 | //go:linkname unsafeZeroArr runtime.zeroVal | ^

ugorji commented 4 years ago

This is surprising.

What OS, Arch are you using?

ugorji commented 4 years ago

This worked on OS X and on Linux, where I develop. It also ran successfully on Travis CI.

And finally, I checked the documentation again, and it is documented to support variables and functions. See

https://golang.org/cmd/compile/ (scroll to bottom of the page)

This special directive does not apply to the Go code that follows it. Instead, the //go:linkname directive instructs the compiler to use “importpath.name” as the object file symbol name for the variable or function declared as “localname” in the source code. If the “importpath.name” argument is omitted, the directive uses the symbol's default object file symbol name and only has the effect of making the symbol accessible to other packages. Because this directive can subvert the type system and package modularity, it is only enabled in files that have imported "unsafe".

Again, what OS/Arch are you using? What go version are you working on? What are you building with?

ugorji commented 4 years ago

Seems you are using gccgo, which has this limitation.

Sending a fix soon.