]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: do not use cache when -a is specified
authorRuss Cox <rsc@golang.org>
Sun, 5 Nov 2017 21:25:00 +0000 (16:25 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 6 Nov 2017 20:17:05 +0000 (20:17 +0000)
Clearly -a means don't use the cache.
An oversight that it did.

Fixes #22586.

Change-Id: I250b351439bd3fb5f8d6efc235b614f0a75ca64c
Reviewed-on: https://go-review.googlesource.com/76016
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/work/buildid.go

index 6c87ce83f8c4de6c0dbbe6e92bc05b22546354e4..a264daa710439b0f1d35e671126d25f5c4c9dedc 100644 (file)
@@ -4728,6 +4728,9 @@ func TestBuildCache(t *testing.T) {
        tg.run("build", "-x", "complex/w")
        tg.grepStderrNot(`[\\/]compile|gccgo`, "ran compiler incorrectly")
 
+       tg.run("build", "-a", "-x", "complex/w")
+       tg.grepStderr(`[\\/]compile|gccgo`, "did not run compiler with -a")
+
        // complex is a non-trivial main package.
        // the link step should not be cached.
        tg.run("build", "-o", os.DevNull, "-x", "complex")
index 35ef1df885ae1ec1e683821ef4325cff46cb67aa..b9e1bab0a3e9b7fe27e64f4f5b4a8fc6c5488cea 100644 (file)
@@ -355,17 +355,19 @@ func (b *Builder) useCache(a *Action, p *load.Package, actionHash cache.ActionID
        // We treat hits in this cache as being "stale" for the purposes of go list
        // (in effect, "stale" means whether p.Target is up-to-date),
        // but we're still happy to use results from the build artifact cache.
-       if c := cache.Default(); c != nil {
-               outputID, size, err := c.Get(actionHash)
-               if err == nil {
-                       file := c.OutputFile(outputID)
-                       info, err1 := os.Stat(file)
-                       buildID, err2 := buildid.ReadFile(file)
-                       if err1 == nil && err2 == nil && info.Size() == size {
-                               a.built = file
-                               a.Target = "DO NOT USE - using cache"
-                               a.buildID = buildID
-                               return true
+       if !cfg.BuildA {
+               if c := cache.Default(); c != nil {
+                       outputID, size, err := c.Get(actionHash)
+                       if err == nil {
+                               file := c.OutputFile(outputID)
+                               info, err1 := os.Stat(file)
+                               buildID, err2 := buildid.ReadFile(file)
+                               if err1 == nil && err2 == nil && info.Size() == size {
+                                       a.built = file
+                                       a.Target = "DO NOT USE - using cache"
+                                       a.buildID = buildID
+                                       return true
+                               }
                        }
                }
        }