1diff --git a/src/go/build/build.go b/src/go/build/build.go
2index b68a712..b60bf19 100644
3--- a/src/go/build/build.go
4+++ b/src/go/build/build.go
5@@ -1708,7 +1708,7 @@ func init() {
6 }
7
8 // ToolDir is the directory containing build tools.
9-var ToolDir = getToolDir()
10+var ToolDir = runtime.GOTOOLDIR()
11
12 // IsLocalImport reports whether the import path is
13 // a local import path, like ".", "..", "./foo", or "../foo".
14diff --git a/src/runtime/extern.go b/src/runtime/extern.go
15index 7171b13..18a942c 100644
16--- a/src/runtime/extern.go
17+++ b/src/runtime/extern.go
18@@ -229,6 +229,17 @@ func GOROOT() string {
19 return sys.DefaultGoroot
20 }
21
22+// GOTOOLDIR returns the root of the Go tree.
23+// It uses the GOTOOLDIR environment variable, if set,
24+// or else the root used during the Go build.
25+func GOTOOLDIR() string {
26+ s := gogetenv("GOTOOLDIR")
27+ if s != "" {
28+ return s
29+ }
30+ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
31+}
32+
33 // Version returns the Go tree's version string.
34 // It is either the commit hash and date at the time of the build or,
35 // when possible, a release tag like "go1.3".