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: |
Updates #48187 Change-Id: I2364f248520e77c2e3a4832b9769b52e7aa62f73 Reviewed-on: https://go-review.googlesource.com/c/go/+/357569 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
This change modifies 'go version' to support shared windows libraries. Updates #48187 Change-Id: I2e8436b8df84fe76677106fa9ca02dcd1fb90e77 Reviewed-on: https://go-review.googlesource.com/c/go/+/391855 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
Change https://go.dev/cl/442035 mentions this issue: |
This change modifies 'go version' to support shared windows libraries. Updates golang#48187 Change-Id: I2e8436b8df84fe76677106fa9ca02dcd1fb90e77 Reviewed-on: https://go-review.googlesource.com/c/go/+/391855 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
Closes golang#48187 Change-Id: Ibb808654bab3b6602b8901423fd297ad1f6e6386 Reviewed-on: https://go-review.googlesource.com/c/go/+/442035 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: David Chase <drchase@google.com>
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: