diff options
author | Russ Cox <rsc@golang.org> | 2023-06-12 16:38:24 -0400 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-06-12 20:59:04 +0000 |
commit | f7e11723e527c1a12e76180e29d52e1fcefce57b (patch) | |
tree | 2e95b2b877d2ea046fe011894ce0a586fc775ad8 | |
parent | c643b2938143ff59d5e854489880e12b39cbfb86 (diff) | |
download | go-f7e11723e527c1a12e76180e29d52e1fcefce57b.tar.gz go-f7e11723e527c1a12e76180e29d52e1fcefce57b.zip |
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>
-rw-r--r-- | src/cmd/dist/build.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 8eb6daa3a5..11f897af4c 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -1496,7 +1496,16 @@ func cmdbootstrap() { // 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 // iterate on local changes without waiting for a full rebuild. - os.Setenv("GOCACHE", oldgocache) + 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) + } if goos == oldgoos && goarch == oldgoarch { // Common case - not setting up for cross-compilation. |