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/go: go version to support non-executable Go binaries #48187
Comments
It sounds like maybe the version info is there, and we don't look for it? /cc @jayconrod @bcmills |
This proposal has been added to the active column of the proposals project |
If there is a straightforward fix to the If the fix is not straightforward, then I think this will ultimately fall into a much-needed “ |
Build info is stamped into files built in It might be very simple to extend
|
Note that we have archive reading code in cmd/link/internal/ld/ar.go. |
If we can tolerate extremely rare false positives, it may also be cheaper and easier not to parse the file at all. See e.g. tailscale/tailscale@a4e19f2. |
We already don't really parse the file, except to find the start of the data segment. Sometimes the data segment is very far into the binary, so we use the parsing to skip to at least the right approximate place. I suppose we could just read the entire file but that's going to be slower. |
It sounds like this is probably pretty easy and that we should just do it. |
Based on the discussion above, this proposal seems like a likely accept. |
Change https://golang.org/cl/357569 mentions this issue: |
I've added some more I haven't added a test for |
No change in consensus, so accepted. |
Change https://go.dev/cl/391855 mentions this issue: |
The
go version
command only supports executable files, restriction that is stated in its documentation:Go version reports the Go version used to build each of the named executable files.
This restriction is implemented by checking for a
.exe
file extension on Windows and by checking if the file has0111
permissions.go/src/cmd/go/internal/version/version.go
Lines 107 to 112 in 4d66d77
I propose that
go version
should also support non-executable binaries, such as binaries compiled usingbuildmode=c-shared
andbuildmode=c-archive
, as these binaries can also contain useful version data.See #45234 for a detailed use-case.
@rsc
The text was updated successfully, but these errors were encountered: