1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:00:04 -07:00

cmd/go: teach the build cache about -trimpath

Fixes #31896

Change-Id: I228a809568cd37c599987f9f1e99df5c229e6c9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/176112
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Caleb Spare 2019-05-08 18:57:00 -07:00 committed by Bryan C. Mills
parent d0aca5759e
commit 1d1ba85d99
2 changed files with 26 additions and 0 deletions

View File

@ -211,6 +211,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch) fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch)
fmt.Fprintf(h, "import %q\n", p.ImportPath) 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) fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix)
if cfg.BuildTrimpath {
fmt.Fprintln(h, "trimpath")
}
if p.Internal.ForceLibrary { if p.Internal.ForceLibrary {
fmt.Fprintf(h, "forcelibrary\n") fmt.Fprintf(h, "forcelibrary\n")
} }
@ -1116,6 +1119,9 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID {
fmt.Fprintf(h, "buildmode %s goos %s goarch %s\n", cfg.BuildBuildmode, cfg.Goos, cfg.Goarch) fmt.Fprintf(h, "buildmode %s goos %s goarch %s\n", cfg.BuildBuildmode, cfg.Goos, cfg.Goarch)
fmt.Fprintf(h, "import %q\n", p.ImportPath) 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) fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix)
if cfg.BuildTrimpath {
fmt.Fprintln(h, "trimpath")
}
// Toolchain-dependent configuration, shared with b.linkSharedActionID. // Toolchain-dependent configuration, shared with b.linkSharedActionID.
b.printLinkerConfig(h, p) b.printLinkerConfig(h, p)

View File

@ -0,0 +1,20 @@
env GO111MODULE=on
# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
cd $WORK
go build -o a.out
# Varying -trimpath should cause a rebuild.
go build -x -o a.out -trimpath
stderr '(compile|gccgo)( |\.exe)'
stderr 'link( |\.exe)'
-- $WORK/hello.go --
package main
func main() { println("hello") }
-- $WORK/go.mod --
module m