-
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: |
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: