mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: strip GOEXPERIMENT from hash salt
The go command salts cache hashes using runtime.Version() (the Go version the go command was built with) in order to separate objects built with different versions of Go. CL 307820 added the active GOEXPERIMENTs to the result of runtime.Version, which affected cmd/go's hash salt. Since dist builds go_bootstrap with all GOEXPERIMENTs disabled, but then go_bootstrap builds the final go binary with the GOEXPERIMENTs passed to make.bash, if any GOEXPERIMENTs were passed, go_bootstrap and the final go binary produce different cache hashes. At the very end of dist, it uses the final go binary to check the hashes of all packages, but these hashes were produced by go_bootstrap, so it concludes everything is stale. This should fix the builders that enable GOEXPERIMENTs, including the regabi and staticlockranking builders. Change-Id: Ie389929dff6f7b6eff2b19a2f43507e72be5f32e Reviewed-on: https://go-review.googlesource.com/c/go/+/308591 Trust: Austin Clements <austin@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
98dd205fa4
commit
793844207d
2 changed files with 17 additions and 2 deletions
2
src/cmd/dist/build.go
vendored
2
src/cmd/dist/build.go
vendored
|
|
@ -1541,7 +1541,7 @@ func checkNotStale(goBinary string, targets ...string) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fatalf("unexpected stale targets reported by %s list -gcflags=\"%s\" -ldflags=\"%s\" for %v:\n%s", goBinary, gogcflags, goldflags, targets, out)
|
fatalf("unexpected stale targets reported by %s list -gcflags=\"%s\" -ldflags=\"%s\" for %v (consider rerunning with GOMAXPROCS=1 GODEBUG=gocachehash=1):\n%s", goBinary, gogcflags, goldflags, targets, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
17
src/cmd/go/internal/cache/hash.go
vendored
17
src/cmd/go/internal/cache/hash.go
vendored
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -36,7 +37,21 @@ type Hash struct {
|
||||||
// of other versions. This salt will result in additional ActionID files
|
// of other versions. This salt will result in additional ActionID files
|
||||||
// in the cache, but not additional copies of the large output files,
|
// in the cache, but not additional copies of the large output files,
|
||||||
// which are still addressed by unsalted SHA256.
|
// which are still addressed by unsalted SHA256.
|
||||||
var hashSalt = []byte(runtime.Version())
|
//
|
||||||
|
// We strip any GOEXPERIMENTs the go tool was built with from this
|
||||||
|
// version string on the assumption that they shouldn't affect go tool
|
||||||
|
// execution. This also allows bootstrapping to converge faster
|
||||||
|
// because dist builds go_bootstrap without any experiments.
|
||||||
|
var hashSalt = []byte(stripExperiment(runtime.Version()))
|
||||||
|
|
||||||
|
// stripExperiment strips any GOEXPERIMENT configuration from the Go
|
||||||
|
// version string.
|
||||||
|
func stripExperiment(version string) string {
|
||||||
|
if i := strings.Index(version, " X:"); i >= 0 {
|
||||||
|
return version[:i]
|
||||||
|
}
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
||||||
// Subkey returns an action ID corresponding to mixing a parent
|
// Subkey returns an action ID corresponding to mixing a parent
|
||||||
// action ID with a string description of the subkey.
|
// action ID with a string description of the subkey.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue