diff options
| author | matloob@golang.org <matloob@golang.org> | 2025-11-11 13:54:52 -0500 |
|---|---|---|
| committer | Michael Matloob <matloob@google.com> | 2025-11-14 09:15:38 -0800 |
| commit | 9daaab305c4d1dede9e4f6efdc5e1268a69327e6 (patch) | |
| tree | 47ff0bc1374e1d9e8b00d79b8664ee7db8de109c /src/cmd/link | |
| parent | d50a571ddfb7661d65c8488b0bbfeacc793f964b (diff) | |
| download | go-9daaab305c4d1dede9e4f6efdc5e1268a69327e6.tar.xz | |
cmd/link/internal/ld: make runtime.buildVersion with experiments valid
Specifically if there are experiments but no nonstandard toolchain
suffix such as "-devel", the go version will not be valid according to
go/version.IsValid. To fix that, always put the X: part into the suffix,
resulting in, for example, go1.25.0-X:foo.
Fixes #75953
Change-Id: I6a6a696468f3ba9b82b6a410fb88831428e93b58
Reviewed-on: https://go-review.googlesource.com/c/go/+/719701
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/cmd/link')
| -rw-r--r-- | src/cmd/link/internal/ld/main.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index d913953944..a4b3a0422f 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -188,7 +188,11 @@ func Main(arch *sys.Arch, theArch Arch) { buildVersion := buildcfg.Version if goexperiment := buildcfg.Experiment.String(); goexperiment != "" { - buildVersion += " X:" + goexperiment + sep := " " + if !strings.Contains(buildVersion, "-") { // See go.dev/issue/75953. + sep = "-" + } + buildVersion += sep + "X:" + goexperiment } addstrdata1(ctxt, "runtime.buildVersion="+buildVersion) |
