aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-02-23 11:47:48 -0500
committerRuss Cox <rsc@golang.org>2015-02-23 19:30:08 +0000
commit264c099ba7988a30ba8d3088c0e925524655383c (patch)
tree4907dddc97b737280a0d2e68d2a86b463998c3c1
parente8d9c8d1631d80aa96fdd8fe0587f09ed5a3332a (diff)
downloadgo-264c099ba7988a30ba8d3088c0e925524655383c.tar.gz
go-264c099ba7988a30ba8d3088c0e925524655383c.zip
[dev.cc] cmd/go: do not install tools while executing them
Change-Id: I3417efc203f555a0a6101701f387ead84f9a08d1 Reviewed-on: https://go-review.googlesource.com/5577 Reviewed-by: Rob Pike <r@golang.org>
-rw-r--r--src/cmd/go/build.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index db1c93b8ac..fba122a04e 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -347,8 +347,26 @@ func runInstall(cmd *Command, args []string) {
var b builder
b.init()
a := &action{}
+ var tools []*action
for _, p := range pkgs {
- a.deps = append(a.deps, b.action(modeInstall, modeInstall, p))
+ // If p is a tool, delay the installation until the end of the build.
+ // This avoids installing assemblers/compilers that are being executed
+ // by other steps in the build.
+ // cmd/cgo is handled specially in b.action, so that we can
+ // both build and use it in the same 'go install'.
+ action := b.action(modeInstall, modeInstall, p)
+ if goTools[p.ImportPath] == toTool && p.ImportPath != "cmd/cgo" {
+ a.deps = append(a.deps, action.deps...)
+ action.deps = append(action.deps, a)
+ tools = append(tools, action)
+ continue
+ }
+ a.deps = append(a.deps, action)
+ }
+ if len(tools) > 0 {
+ a = &action{
+ deps: tools,
+ }
}
b.do(a)
}