From: Russ Cox Date: Tue, 13 Nov 2018 15:09:22 +0000 (-0500) Subject: cmd/go: fix experiment isolation in cache key X-Git-Tag: go1.12beta1~330 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=94f7795d05937fdf6187c7f850f8902c0f7a6d81;p=gostls13.git cmd/go: fix experiment isolation in cache key 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 --- diff --git a/src/cmd/go/internal/work/buildid.go b/src/cmd/go/internal/work/buildid.go index c5aa1db50b..750bc3c6cd 100644 --- a/src/cmd/go/internal/work/buildid.go +++ b/src/cmd/go/internal/work/buildid.go @@ -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() diff --git a/src/cmd/internal/objabi/flag.go b/src/cmd/internal/objabi/flag.go index 30cd7dccac..90e944656b 100644 --- a/src/cmd/internal/objabi/flag.go +++ b/src/cmd/internal/objabi/flag.go @@ -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