]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: more refined handling of cmd/compile magic environment variables
authorRuss Cox <rsc@golang.org>
Fri, 10 Nov 2017 19:50:03 +0000 (14:50 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 13 Nov 2017 14:57:09 +0000 (14:57 +0000)
Per discussion with David Chase, need to check GOSSAHASH$n
for increasing n until one is missing. Also if GSHS_LOGFILE is set,
the compiler writes to that file, so arrange never to cache in that case.

Change-Id: I3931b4e296251b99abab9bbbbbdcf94ae8c1e2a6
Reviewed-on: https://go-review.googlesource.com/77111
Reviewed-by: David Chase <drchase@google.com>
src/cmd/go/internal/work/exec.go

index 44f4a91ca5a3c98c0eccbf44205e1991b0858f55..08f7d00da1b575e104f1db6d5f0b60b1c5301769 100644 (file)
@@ -223,7 +223,6 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
                        "GOCLOBBERDEADHASH",
                        "GOSSAFUNC",
                        "GO_SSA_PHI_LOC_CUTOFF",
-                       "GSHS_LOGFILE",
                        "GOSSAHASH",
                }
                for _, env := range magic {
@@ -231,6 +230,23 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
                                fmt.Fprintf(h, "magic %s=%s\n", env, x)
                        }
                }
+               if os.Getenv("GOSSAHASH") != "" {
+                       for i := 0; ; i++ {
+                               env := fmt.Sprintf("GOSSAHASH%d", i)
+                               x := os.Getenv(env)
+                               if x == "" {
+                                       break
+                               }
+                               fmt.Fprintf(h, "magic %s=%s\n", env, x)
+                       }
+               }
+               if os.Getenv("GSHS_LOGFILE") != "" {
+                       // Clumsy hack. Compiler writes to this log file,
+                       // so do not allow use of cache at all.
+                       // We will still write to the cache but it will be
+                       // essentially unfindable.
+                       fmt.Fprintf(h, "nocache %d\n", time.Now().UnixNano())
+               }
        }
 
        // Input files.