From: Russ Cox Date: Thu, 4 Jun 2015 19:35:58 +0000 (-0400) Subject: cmd/go: include Go toolchain information in build ID X-Git-Tag: go1.5beta1~251 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ab9ff11072b0bd9852011b82b00d30c6ee04c4e;p=gostls13.git cmd/go: include Go toolchain information in build ID This causes packages and binaries built by Go 1.5 to look out of date to Go 1.6 and vice versa, so that when you flip between different Go versions but keep the same GOPATH, the right rebuilding happens at each flip. Go 1.4 binaries will also look out of date to Go 1.5, but Go 1.5 binaries will not look out of date to Go 1.4 (since Go 1.4 doesn't have anything like this). People flipping between Go 1.4 and Go 1.5 will still need to use go install -a every time to flip to Go 1.4, but not when they flip back to Go 1.5. Fixes #6534. Fixes #10702. Change-Id: I0ae7f268f822d483059a938a4f22846ff9275b4c Reviewed-on: https://go-review.googlesource.com/10760 Reviewed-by: Ian Lance Taylor Reviewed-by: Andrew Gerrand --- diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go index 73527a3aba..7b21fd4414 100644 --- a/src/cmd/go/pkg.go +++ b/src/cmd/go/pkg.go @@ -724,6 +724,27 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package for _, file := range inputFiles { fmt.Fprintf(h, "%s\n", file) } + + // Include the content of runtime/zversion.go in the hash + // for package runtime. This will give package runtime a + // different build ID in each Go release. + if p.Standard && p.ImportPath == "runtime" { + data, _ := ioutil.ReadFile(filepath.Join(p.Dir, "zversion.go")) + fmt.Fprintf(h, "zversion %q\n", string(data)) + } + + // Include the build IDs of any dependencies in the hash. + // This, combined with the runtime/zversion content, + // will cause packages to have different build IDs when + // compiled with different Go releases. + // This helps the go command know to recompile when + // people use the same GOPATH but switch between + // different Go releases. See golang.org/issue/10702. + for _, dep := range p.Deps { + p1 := deps[dep] + fmt.Fprintf(h, "dep %s %s\n", p1.ImportPath, p1.buildID) + } + p.buildID = fmt.Sprintf("%x", h.Sum(nil)) return p