Hi, *>Thanks for your attention, but I tried to write a demo with go:linkname.* *>In fact, it works well with gollvm...So maybe it is not the exact cause for the problem*
The problem is not that gollvm fails to implement go:linkname-- the problem is the way that this package (http://github.com/ugorji/go) is using go:linkname. The Go runtime and standard library has a public, exported API; this sort of use of go:linkname to reach into the internals of a standard package (in this case, calling an unexported function) is not supported. Folks who write such code should understand that it can break at any time from release to release or across Go implementations. Than On Mon, Mar 29, 2021 at 3:35 AM JX Zhang <f0110v...@gmail.com> wrote: > > go:linkname to refer directly to functions that are defined but not > exported by the standard library. > > This is not supported and is likely to break with any new release. It > evidently breaks with GoLLVM. > > Thanks for your attention, but I tried to write a demo with go:linkname. > In fact, it works well with gollvm...So maybe it is not the exact cause > for the problem > > Herei is my code: > > hello/hello.go > ``` > package hello > > import ( > "fmt" > _ "unsafe" > ) > //go:linkname hellox hello.hellox > func hellox(x string) { > fmt.Println(x) > } > ``` > > main.go > ``` > package main > > import ( > _ "mypackage/hello" > _ "unsafe" > ) > > //go:linkname hel hello.hellox > func hel(x string) > > func main() { > hel("aaa") > //println("aaaa") > } > ``` > > 在2021年3月29日星期一 UTC+8 上午12:37:49<Ian Lance Taylor> 写道: > >> On Sun, Mar 28, 2021 at 9:28 AM 张嘉熙 <f011...@gmail.com> wrote: >> > >> > For s2-geojson, I meet: >> > ``` >> > # github.com/pantrif/s2-geojson/cmd/s2-geojson >> > >> /home/jx/.cache/go-build/6b/6bd003c99eb0a9e7c6ea6d372307b292ec615c75c28f9b1f696896ae2fb4272b-d(_go_.o):gomodule:function >> github_0com_1ugorji_1go_1codec.intf2impls.intf2impl: error: undefined >> reference to 'reflect.unsafe_New' >> > >> /home/jx/.cache/go-build/6b/6bd003c99eb0a9e7c6ea6d372307b292ec615c75c28f9b1f696896ae2fb4272b-d(_go_.o):gomodule:function >> github_0com_1ugorji_1go_1codec.Decoder.interfaceExtConvertAndDecode: error: >> undefined reference to 'reflect.unsafe_New' >> > decode.go:509: error: undefined reference to 'reflect.unsafe_New' >> > decode.go:14935: error: undefined reference to 'reflect.unsafe_New' >> >> This is a problem with github.com/ugorji/go. The file >> code/helper_unsafe.go uses go:linkname to refer directly to functions >> that are defined but not exported by the standard library. This is >> not supported and is likely to break with any new release. It >> evidently breaks with GoLLVM. >> >> Ian >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/5d763cdf-1147-4abe-aea7-9f6efa39e930n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/5d763cdf-1147-4abe-aea7-9f6efa39e930n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2BUr55H4Q4%2BoztZjm3ZcrsFdQ-gBvy_V9WE%3D-Y3CnoTHWLFuqg%40mail.gmail.com.