From 9a97a2aae9e16ad9cd5fbed7c7ab8a10fe6f2673 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 2 Jul 2018 16:48:29 -0700 Subject: [PATCH] cmd/go: add ForceLibrary to build hash When a command has a test that is not in package main, the main package is built as a library, with ForceLibrary set. It can of course also be built as an ordinary main package. If we don't record that fact in the hash, then both variants of the command will use the same hash, which causes a GODEBUG=gocacheverify=1 failure. It also seems unsafe although it's not clear to me whether it can cause an actual failure. Along with CL 121941, Fixes #25666 Change-Id: I115ad249012f30fbe45cd0c41da86adc295fe4b2 Reviewed-on: https://go-review.googlesource.com/121942 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/go/internal/work/exec.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 5c4dc88821..9a5a0dfc8e 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -203,6 +203,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID { fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch) fmt.Fprintf(h, "import %q\n", p.ImportPath) fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix) + if p.Internal.ForceLibrary { + fmt.Fprintf(h, "forcelibrary\n") + } if len(p.CgoFiles)+len(p.SwigFiles) > 0 { fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo")) cppflags, cflags, cxxflags, fflags, _, _ := b.CFlags(p) -- 2.50.0