blob: 9aa0119ae925d30acb8fcd1825b4734276a98863 [file] [log] [blame]
Brad Bishop1d80a2e2019-11-15 16:35:03 -05001From 28ada8896b76d620240bafc22aa395071d601482 Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Wed, 23 Oct 2019 21:15:37 +0430
4Subject: [PATCH 3/9] cmd/go: Allow GOTOOLDIR to be overridden in the environment
5
6to allow for split host/target build roots
7
8Adapted to Go 1.13 from patches originally submitted to
9the meta/recipes-devtools/go tree by
10Matt Madison <matt@madison.systems>.
11
12Upstream-Status: Inappropriate [OE specific]
13
14Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
15---
16 src/cmd/dist/build.go | 4 +++-
17 src/cmd/go/internal/cfg/cfg.go | 6 +++++-
18 2 files changed, 8 insertions(+), 2 deletions(-)
19
20diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
21index 9e50311..683ca6f 100644
22--- a/src/cmd/dist/build.go
23+++ b/src/cmd/dist/build.go
24@@ -244,7 +244,9 @@ func xinit() {
25 workdir = xworkdir()
26 xatexit(rmworkdir)
27
28- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
29+ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
30+ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
31+ }
32 }
33
34 // compilerEnv returns a map from "goos/goarch" to the
35diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
36index a3277a6..db96350 100644
37--- a/src/cmd/go/internal/cfg/cfg.go
38+++ b/src/cmd/go/internal/cfg/cfg.go
39@@ -60,7 +60,11 @@ func defaultContext() build.Context {
40 // variables. This matches the initialization of ToolDir in
41 // go/build, except for using ctxt.GOROOT rather than
42 // runtime.GOROOT.
43- build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
44+ if s := os.Getenv("GOTOOLDIR"); s != "" {
45+ build.ToolDir = filepath.Clean(s)
46+ } else {
47+ build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
48+ }
49 }
50
51 ctxt.GOPATH = envOr("GOPATH", ctxt.GOPATH)
52--
532.17.1 (Apple Git-112)
54