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
cmd/link: put toolchain version in binary #13507
Comments
@randall77 i'd like to see this as well. A few years ago I suggested (cannot find the issue # anymore) that runtime.Version be printed in panic output. Doing this would solve the problem of keeping runtime.buildVersion alive, and also avoid having to much about with gdb to find the version string. |
we already have https://golang.org/cl/117040043 It's now called runtime/internal/sys.BuildVersion (gdb) p 'runtime/internal/sys.BuildVersion' The variable will never be eliminated due to its Go 1.6 is the first version that the string is moved to |
Ok, excellent, didn't know about that one. I'm not sure moving back to runtime.buildVersion would help. runtime.buildVersion isn't reliable in 1.4 because it can be eliminated at link time. |
The change first appeared in Go 1.4, so starting from Go 1.4,
runtime.buildVersion is always available, until Go 1.6.
|
CL https://golang.org/cl/17459 mentions this issue. |
What about programs built with gccgo? |
@laboger For gccgo |
…sion So that there is a uniformed way to retrieve Go version from a Go binary, starting from Go 1.4 (see https://golang.org/cl/117040043) Updates #13507. Change-Id: Iaa2b14fca2d8c4d883d3824e2efc82b3e6fe2624 Reviewed-on: https://go-review.googlesource.com/17459 Reviewed-by: Keith Randall <khr@golang.org>
It would be nice to have a robust mechanism to tell what version of Go built a particular binary.
See go-nuts thread: https://groups.google.com/forum/#!topic/golang-nuts/XIDDj75ngMc
If the binary happens to call runtime.Version, then the version of Go is stored in runtime.buildVersion. If it doesn't call runtime.Version, runtime.buildVersion is dead-symbol eliminated.
We could teach cmd/link not to remove this symbol even if it is dead. Probably better is to just reference runtime.buildVersion from some always-used code (schedinit?). That way it will always be available in the binary, easily extracted with gdb.
The text was updated successfully, but these errors were encountered: