blob: 818fe66700a230b2eb7c9126b5c341067a39ce5c [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From acd179b49f1fc8d6f7f69e569fb4a56039c725a1 Mon Sep 17 00:00:00 2001
2From: Matt Madison <matt@madison.systems>
3Date: Sat, 17 Feb 2018 05:24:20 -0800
4Subject: [PATCH 3/9] allow GOTOOLDIR to be overridden in the environment
5
6to allow for split host/target build roots
7
8Upstream-Status: Inappropriate [OE specific]
9
10Signed-off-by: Matt Madison <matt@madison.systems>
11---
12 src/cmd/dist/build.go | 4 +++-
13 src/cmd/go/internal/cfg/cfg.go | 6 +++++-
14 src/go/build/build.go | 2 +-
15 3 files changed, 9 insertions(+), 3 deletions(-)
16
17diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
18index 49ed80033e..afc615b5c2 100644
19--- a/src/cmd/dist/build.go
20+++ b/src/cmd/dist/build.go
21@@ -220,7 +220,9 @@ func xinit() {
22 workdir = xworkdir()
23 xatexit(rmworkdir)
24
25- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
26+ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
27+ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
28+ }
29 }
30
31 // compilerEnv returns a map from "goos/goarch" to the
32diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
33index 1de4f0dc79..4f6010d660 100644
34--- a/src/cmd/go/internal/cfg/cfg.go
35+++ b/src/cmd/go/internal/cfg/cfg.go
36@@ -96,7 +96,11 @@ func init() {
37 // as the tool directory does not move based on environment variables.
38 // This matches the initialization of ToolDir in go/build,
39 // except for using GOROOT rather than runtime.GOROOT().
40- build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
41+ if s := os.Getenv("GOTOOLDIR"); s != "" {
42+ build.ToolDir = filepath.Clean(s)
43+ } else {
44+ build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
45+ }
46 }
47
48 func findGOROOT() string {
49diff --git a/src/go/build/build.go b/src/go/build/build.go
50index 68fb423983..81b1b32270 100644
51--- a/src/go/build/build.go
52+++ b/src/go/build/build.go
53@@ -1594,7 +1594,7 @@ func init() {
54 }
55
56 // ToolDir is the directory containing build tools.
57-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
58+var ToolDir = envOr("GOTOOLDIR", filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH))
59
60 // IsLocalImport reports whether the import path is
61 // a local import path, like ".", "..", "./foo", or "../foo".
62--
632.14.1
64