Skip to content
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/dist: enforce the lowest bootstrap version #69168

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/cmd/dist/buildtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package main

import (
"fmt"
"go/version"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -118,9 +119,11 @@ var ignoreSuffixes = []string{
"~",
}

const minBootstrap = "go1.22.6"

var tryDirs = []string{
"sdk/go1.22.6",
"go1.22.6",
"sdk/" + minBootstrap,
minBootstrap,
}

func bootstrapBuildTools() {
Expand All @@ -134,6 +137,15 @@ func bootstrapBuildTools() {
}
}
}

// check bootstrap version.
ver := run(pathf("%s/bin", goroot_bootstrap), CheckExit, pathf("%s/bin/go", goroot_bootstrap), "env", "GOVERSION")
// go env GOVERSION output like "go1.22.6\n" or "devel go1.24-ffb3e574 Thu Aug 29 20:16:26 2024 +0000\n".
ver = ver[:len(ver)-1]
if version.Compare(ver, version.Lang(minBootstrap)) > 0 && version.Compare(ver, minBootstrap) < 0 {
fatalf("%s does not meet the minimum bootstrap requirement of %s or later", ver, minBootstrap)
}

xprintf("Building Go toolchain1 using %s.\n", goroot_bootstrap)

mkbuildcfg(pathf("%s/src/internal/buildcfg/zbootstrap.go", goroot))
Expand Down