]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix experiment isolation in cache key
authorRuss Cox <rsc@golang.org>
Tue, 13 Nov 2018 15:09:22 +0000 (10:09 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 16 Nov 2018 17:50:00 +0000 (17:50 +0000)
In general we don't assume that the go command knows the
specific version of the compiler being used, including which
experiments the compiler was built with. Let the compiler tell us,
instead of importing cmd/internal/objabi from cmd/go.

Replacement for CL 128735.

Change-Id: Iaa07f46e19764d0fb14a1c89979bea7bb7139b9c
Reviewed-on: https://go-review.googlesource.com/c/149338
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/work/buildid.go
src/cmd/internal/objabi/flag.go

index c5aa1db50b8d6077c7d31158f4c8551681f291f1..750bc3c6cdbe450e5c6e87bd953bd174a61ee974 100644 (file)
@@ -18,7 +18,6 @@ import (
        "cmd/go/internal/load"
        "cmd/go/internal/str"
        "cmd/internal/buildid"
-       "cmd/internal/objabi"
 )
 
 // Build IDs
@@ -208,11 +207,6 @@ func (b *Builder) toolID(name string) string {
                id = f[2]
        }
 
-       // For the compiler, add any experiments.
-       if name == "compile" {
-               id += " " + objabi.Expstring()
-       }
-
        b.id.Lock()
        b.toolIDCache[name] = id
        b.id.Unlock()
index 30cd7dccac20fbee7cbc73850b7c55a8852559ac..90e944656bb8a2ebeca5dd2d593ac0a124a222f6 100644 (file)
@@ -100,9 +100,18 @@ func (versionFlag) Set(s string) error {
        // for releases, but during development we include the full
        // build ID of the binary, so that if the compiler is changed and
        // rebuilt, we notice and rebuild all packages.
-       if s == "full" && strings.HasPrefix(Version, "devel") {
-               p += " buildID=" + buildID
+       if s == "full" {
+               // If there's an active experiment, include that,
+               // to distinguish go1.10.2 with an experiment
+               // from go1.10.2 without an experiment.
+               if x := Expstring(); x != "" {
+                       p += " " + x
+               }
+               if strings.HasPrefix(Version, "devel") {
+                       p += " buildID=" + buildID
+               }
        }
+
        fmt.Printf("%s version %s%s%s\n", name, Version, sep, p)
        os.Exit(0)
        return nil