-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/dist, x/build/cmd/golangbuild: switch to a devel version format that satisfies go/version.Lang and go/version.IsValid in more cases #73372
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
Comments
I am perfectly happy with the So this change to golangbuild sounds good if we make the same change to cmd/dist, otherwise it seems we should change golangbuild to be in line with dist. [1] Why does golangbuild need to generate a VERSION file at all? |
Yes, agreed, we should apply this to cmd/dist too. Retitled to capture that too. As for why golangbuild (and coordinator, previously) generates a VERSION file, it does it for a few related reasons:
|
There is also need to identify downstream golang toolchains, their vendor, and patch level. In a way that is encoded in the binaries built by those toolchains. And then distributed to another party and be able to link it all back. I wonder, if it is best to keep the top level version as short as possible, and still semver compliant. And have more verbose and structured information about the toolchain in the buildinfo, which propagates to the binaries.
Similarly this would be very useful for downstreams to embed toolchain.vendor and toolchain.vendor-version. Very often many parties are involved as to who creates the golang toolchain, who builds the binaries, by whom/where they are deployed. If one uses a linux distribution golang fork with backported CVEs today, builds go binaires, puts them into container, and pushes it to dockerhub or as a UBI, and somebody else deploys them, it is impossible to tell from the go binary alone which golang was used and if it was 1.23.3 from upstream, or a particular linux vendor, which vendor, and if it has backported CVE fixes. Not too dissimilar with being able to identify snapshot builds, and pre-release builds. If you can, please consider adding structured data about the toolchain to the buildinfo that persists in binaries beyond the top level "go1.x" string. |
@xnox Including additional fields about the toolchain and its possible modifications in the build information (in addition to the go version string) like that is an interesting idea. It has some connection with the idea of having |
Change https://go.dev/cl/667955 mentions this issue: |
Change https://go.dev/cl/668015 mentions this issue: |
Non-release versions that are built from source without a VERSION file specifying any particular version end up with a development version like "devel go1.25-67e0681aef Thu Apr 24 12:17:27 2025 -0700". Right now those versions are correctly determined to be non-release because they don't have a "go" prefix, instead they have a "devel " prefix. In preparation of being able to move the "devel" substring, add a check that said substring isn't present anywhere, since it is certain not to be included in any released Go version we publish at https://go.dev/dl/. For #73372. Change-Id: Ia3e0d03b5723d4034d6270c3a2224f8dfae380e9 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/667955 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Change https://go.dev/cl/668355 mentions this issue: |
Change https://go.dev/cl/669016 mentions this issue: |
The intention of TestVetStdlib is to run and potentially fail only at Go tip, where standard library code can be relatively easily modified. The current skip logic relies on the property that the "devel" string, something that we aim to include in all non-release versions, happens to be a prefix only at Go tip. That won't be the case after the issue go.dev/issue/73372 is resolved, so update the skip to keep working as originally intended. For golang/go#73372. Change-Id: I122439a590782f86fc3b3a8ba4b3adbfee1e591f Reviewed-on: https://go-review.googlesource.com/c/tools/+/669016 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
These were the remaining instances in the main Go repo I found where a Go version like "devel go1.25-9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700" is considered to be a development version rather than a release version, but the version "go1.25-devel_9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700" is not. Update this in preparation of the move of "devel" from front to middle. For #73372. For #73369. Change-Id: If5442ecb0751c08b3a1b4d1148193e501700b956 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/668355 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
I was struggling with this just last week - thanks so much for this change! |
golangbuild currently generates VERSION files with strings like this, a behavior that the Go build system had for a while:
Which is broadly based on make.bash's auto-detection logic used to construct a version when a VERSION file specifying it isn't present, which generates version strings in a similar format (the "go1.X-" prefix being new as of CL 264938):
That format satisfies the property that a "devel" substring is present, but not the property that go/version.IsValid is true and go/version.Lang works on it.
As motivated in #73369 (comment), I suggest we change to the following format that have all of the aforementioned properties:
Where
go1.X
corresponds to the language version specified in internal/goversion.Version, something golangbuild has easy access to. Something to consider including .0 likego1.X.0-devel_...
, but given the first pre-release version (e.g., go1.25rc1) leaves it out, maybe its fine to leave it out too. Since this is just a development version which isn't tagged or published anywhere, changing it if we find a need to shouldn't be too expensive.There might be test cases or other code that relies on the current format, such as checking for "devel" prefix (or its absence), that'd need to be updated as part of this.
golangbuild.maybeUpdateVersionFile diff
CC @golang/release, @prattmic.
The text was updated successfully, but these errors were encountered: