Open eat-swap opened 3 years ago
For some reason, in GCC 11 reflect.unsafe_New
function was renamed to reflect.unsafe__New
with two underscore. Compare:
mymedia@freesia:~$ nm -D --defined-only /usr/lib/gcc/x86_64-linux-gnu/10/libgo.so | grep 'unsafe_*New'
0000000000f05d00 T internal..z2freflectlite.unsafe_New
0000000000f05cc0 T reflect.unsafe_New
0000000000f03150 T reflect.unsafe_NewArray
mymedia@freesia:~$ nm -D --defined-only /usr/lib/gcc/x86_64-linux-gnu/11/libgo.so | grep 'unsafe_*New'
000000000100c920 T internal_1reflectlite.unsafe__New
000000000100c8e0 T reflect.unsafe__New
000000000100ca30 T reflect.unsafe__NewArray
I can verify this, and unfortunately, the problem only happens in gccgo or gollvm. Both are using a different port of libgo in gofrontend.
The mainstream go compiler: https://github.com/golang/go/blob/41b9d8c75e45636a153c2a31d117196a22a7fc6c/src/runtime/malloc.go#L1201
The libgo port for gccgo and gollvm: https://github.com/golang/gofrontend/blob/f5bc28a30b7503015bbef38afb5812313184e822/libgo/go/runtime/malloc.go#L1295
It is not clear how to fix this issue. Because go doesn't have a quick check over the defined/undefined symbols.
For people building gccgo or gollvm: It is best to make a copy of these functions and make both verions available unsafe_
and unsafe__
.
For people using a distributed version of gccgo or gollvm: Fix the library call in unsafe_link.go
into using unsafe__
.
A related issue, if you use https://github.com/ugorji/go, fix codec/helper_unsafe.go
as above.
Hello! I have tried to compile my own project which has a dependency of "reflect2" package with the most recent gccgo but failed with a message of "undefined reference". Is it possible to make it compile using gccgo?
Details shown below:
What version of "reflect2" is used to compile?
The most recent commit (commit
333559e1834b0c1840d283d79220bf121d704022
).What version of Go are you using (
go version
)?Additionally,
gccgo --version
tells:What operating system and processor architecture are you using?
What did you do?
Trying to build some code that depends on this package.
What is expected to see?
The code successfully compiles.
What you see instead?
Thanks for your patient and effort.