-
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
go:linkname must refer to declared function or variable #51706
Comments
reaching into the runtime isn't supported Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
I had the same issue running go 1.18 today - the solution on this thread solved it for me. I don't think the variable name runtime has anything to do with it. This does seem like it might be a bug of some kind given I fresh installed go on a fresh image and had source code version mismatching going on. |
Underlying issue: golang/go#51706
Build is failing on osx due to the following error: ``` vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go:27:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go:40:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:28:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:43:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:59:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:75:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:90:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:105:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:121:3: //go:linkname must refer to declared function or variable vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:121:3: too many errors ``` Upgrading sys package resolves the issue. Discussions: golang/go#51706
Co-authored-by: Sergey Dobrodey <[email protected]>
golang/go#51706 by updating golang.org/x/sys to the latest version
golang/go#51706 by updating golang.org/x/sys to the latest version
To summarise the fix in case of linkrot, try:
to update |
Even after upgrading the golang.org/x/sys package, the problem is still not solved, why close this issue |
We appear to be conflating two issues here. (1) People who try to use This is what the original author mentioned, and Sean is right to have closed the issue - you are free to use the linker directive, but you're on your own when it breaks. In fact, I even struggle to find any official documentation that explains how to use (2) People who get build errors with a particular versions of Go and As you can see on https://build.golang.org/, the "x" modules like Similarly, if your Go version is recent, you should make sure your |
hi @mvdan Whether it's a |
project:
inner.go:
main.go:
run result in 1.17 version:
result in 1.18 and later:
I didn't import the x/sys package or the runtime package, I think should get the same result in different versions |
I found that in version 1.18 and later, functions and variables still work, the linkname for struct is not supported, but I didn't find instructions in the official documentation |
See https://go-review.googlesource.com/c/go/+/333109/. Once again, |
ok, since there is not documented nor supported then I have nothing to say |
go/src/cmd/compile/internal/noder/noder.go Lines 291 to 310 in 15da892
Lines 16 to 30 in 15da892
i think may be the error in 1.17, type |
You can't use |
I got an error: ../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable golang/go#51706 (comment) I updated golang.org/x/sys according to the above instructions.
I got an error: ../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable golang/go#51706 (comment) I updated golang.org/x/sys according to the above instructions.
I got an error: ../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable golang/go#51706 (comment) I updated golang.org/x/sys according to the above instructions.
it's powerful |
Sounds like this was definitely a bug report since upgrading the package fixed it. |
I agree with your point of view, just looks a little confused that 1.18 and later versions will report an error,but 1.17 don't report an error |
Update `golang.org/x/sys` package to address golang/go#51706 Update bazel `rules_go` to address bazel-contrib/rules_go#3199
Update `golang.org/x/sys` package to address golang/go#51706 Update bazel `rules_go` to address bazel-contrib/rules_go#3199
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
I think runtimeG is declared in main.go, And it works well in version 1.17.8 and 1.16.4
Maybe I'm using it incorrectly, hope it clears my mind, thanks very much!
The text was updated successfully, but these errors were encountered: