Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 1 | From 28ada8896b76d620240bafc22aa395071d601482 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alex Kube <alexander.j.kube@gmail.com> |
| 3 | Date: Wed, 23 Oct 2019 21:15:37 +0430 |
| 4 | Subject: [PATCH 3/9] cmd/go: Allow GOTOOLDIR to be overridden in the environment |
| 5 | |
| 6 | to allow for split host/target build roots |
| 7 | |
| 8 | Adapted to Go 1.13 from patches originally submitted to |
| 9 | the meta/recipes-devtools/go tree by |
| 10 | Matt Madison <matt@madison.systems>. |
| 11 | |
| 12 | Upstream-Status: Inappropriate [OE specific] |
| 13 | |
| 14 | Signed-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 | |
| 20 | diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go |
| 21 | index 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 |
| 35 | diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go |
| 36 | index 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 | -- |
| 53 | 2.17.1 (Apple Git-112) |
| 54 | |