1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:40:04 -07:00

cmd/dist: do not use user build cache in versioned trees

There is no guarantee that the user build cache will have
correct data if we are using a versioned build (with a VERSION file),
because that overrides the use of tool build IDs for staleness.
An earlier build might have run with a buggy compiler, and we don't
want those files lying around.

Change-Id: I831956911162ccbd0b4d943c305b3537918fe119
Reviewed-on: https://go-review.googlesource.com/c/go/+/502699
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
This commit is contained in:
Russ Cox 2023-06-12 16:38:24 -04:00 committed by Gopher Robot
parent c643b29381
commit f7e11723e5

View File

@ -1496,7 +1496,16 @@ func cmdbootstrap() {
// Now prime the build cache with the rest of the standard library for // Now prime the build cache with the rest of the standard library for
// testing, and so that the user can run 'go install std cmd' to quickly // testing, and so that the user can run 'go install std cmd' to quickly
// iterate on local changes without waiting for a full rebuild. // iterate on local changes without waiting for a full rebuild.
if _, err := os.Stat(pathf("%s/VERSION", goroot)); err == nil {
// If we have a VERSION file, then we use the Go version
// instead of build IDs as a cache key, and there is no guarantee
// that code hasn't changed since the last time we ran a build
// with this exact VERSION file (especially if someone is working
// on a release branch). We must not fall back to the shared build cache
// in this case. Leave $GOCACHE alone.
} else {
os.Setenv("GOCACHE", oldgocache) os.Setenv("GOCACHE", oldgocache)
}
if goos == oldgoos && goarch == oldgoarch { if goos == oldgoos && goarch == oldgoarch {
// Common case - not setting up for cross-compilation. // Common case - not setting up for cross-compilation.