1 From 5c32c38bf19b24f0aadd78012d17ff5caa82151e Mon Sep 17 00:00:00 2001
2 From: Matt Madison <matt@madison.systems>
3 Date: Sat, 17 Feb 2018 05:24:20 -0800
4 Subject: [PATCH] allow GOTOOLDIR to be overridden in the environment
6 to allow for split host/target build roots
8 Upstream-Status: Inappropriate [OE specific]
10 Signed-off-by: Matt Madison <matt@madison.systems>
13 src/cmd/dist/build.go | 4 +++-
14 src/cmd/go/internal/cfg/cfg.go | 7 +++++--
15 2 files changed, 8 insertions(+), 3 deletions(-)
17 Index: go/src/cmd/dist/build.go
18 ===================================================================
19 --- go.orig/src/cmd/dist/build.go
20 +++ go/src/cmd/dist/build.go
21 @@ -228,7 +228,9 @@ func xinit() {
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)
31 // compilerEnv returns a map from "goos/goarch" to the
32 Index: go/src/cmd/go/internal/cfg/cfg.go
33 ===================================================================
34 --- go.orig/src/cmd/go/internal/cfg/cfg.go
35 +++ go/src/cmd/go/internal/cfg/cfg.go
36 @@ -116,7 +116,11 @@ func init() {
37 // variables. This matches the initialization of ToolDir in
38 // go/build, except for using GOROOT rather than
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)
44 + build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)