Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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 |
| 5 | |
| 6 | to allow for split host/target build roots |
| 7 | |
| 8 | Upstream-Status: Inappropriate [OE specific] |
| 9 | |
| 10 | Signed-off-by: Matt Madison <matt@madison.systems> |
| 11 | |
| 12 | --- |
| 13 | src/cmd/dist/build.go | 4 +++- |
| 14 | src/cmd/go/internal/cfg/cfg.go | 7 +++++-- |
| 15 | 2 files changed, 8 insertions(+), 3 deletions(-) |
| 16 | |
| 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() { |
| 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 |
| 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 |
| 39 | // 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 | |