-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
golang 1.17.beta1, //go:linkname relocate not defined #46777
Comments
What are you actually trying to accomplish? I don't think linknaming to low-level runtime names is supported or guaranteed to keep working between Go versions. In general, you should be using |
Using linkname to access to unexported runtime symbols are not supported. Closing as working as intended. |
@cherrymui , this is a mini test case. on golang 1.16 or before version, this case compile is ok, on golang 1.17 beta1, it compile errors. Plan to stop support this feature on newer version? |
Using |
@ianlancetaylor |
use the following instead, in golang1.17beta1 is ok //go:linkname uncommon runtime.(_type).uncommon |
I want to be clear that it may work but it is not OK for production code. Writing code like this will break in future releases. |
this package compile on fixed version, on new releases will be try to adapt. Thanks for your kind interpretation. |
I've tried both when golang 1.16 released. Sad to know this inconvenient change happen to the compiler. @pkujhd Would you please find related leads inside the NEW compiler, so we can REVERT it or leverage it. |
@AZ-X your problem is not same with mine. walltime() is removed from runtime package. my problem is a struct member function can not relocat in golang 1.17. |
I don't think they will take responsible for that. Perhaps you didn't get my problem related to this topic. |
I just made these stuff compiled via my custom patch base on the compiler shipped with golang 1.17.2. @pkujhd FYI. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
no
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
pkujhd@pkujhd t % cat main.go
package main
import (
"fmt"
_ "runtime"
"unsafe"
)
type _type struct {
}
type uncommonType struct {
}
//go:linkname (_type).uncommon runtime.(_type).uncommon
func (t *_type) uncommon() *uncommonType
func main() {
a := _type{}
b := unsafe.Pointer(&a)
fmt.Println(a.uncommon(), b)
}
pkujhd@pkujhd t % ls -l *
-rw-r--r-- 1 pkujhd staff 0 6 16 11:56 empty.asm.s
-rw-r--r-- 1 pkujhd staff 294 6 16 13:24 main.go
pkujhd@pkujhd t % go build
What did you expect to see?
build ok
What did you see instead?
main.main: relocation target main.(*_type).uncommon not defined
on golang 1.16.4, build ok
The text was updated successfully, but these errors were encountered: