// to break if we don't automatically refresh things here.
// Rebuilding is a shortened bootstrap.
// See cmdbootstrap for a description of the overall process.
- if !t.listMode {
+ //
+ // But don't do this if we're running in the Go build system,
+ // where cmd/dist is invoked many times. This just slows that
+ // down (Issue 24300).
+ if !t.listMode && os.Getenv("GO_BUILDER_NAME") == "" {
goInstall("go", append([]string{"-i"}, toolchain...)...)
goInstall("go", append([]string{"-i"}, toolchain...)...)
goInstall("go", "std", "cmd")