Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame^] | 1 | From 5cca2fa5997292a87302bdc7e7ed3231371e98bd 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 2/9] cmd/go: Allow GOTOOLDIR to be overridden in the |
| 5 | environment |
| 6 | |
| 7 | to allow for split host/target build roots |
| 8 | |
| 9 | Adapted to Go 1.13 from patches originally submitted to |
| 10 | the meta/recipes-devtools/go tree by |
| 11 | Matt Madison <matt@madison.systems>. |
| 12 | |
| 13 | Upstream-Status: Inappropriate [OE specific] |
| 14 | |
| 15 | Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> |
| 16 | --- |
| 17 | src/cmd/dist/build.go | 4 +++- |
| 18 | src/cmd/go/internal/cfg/cfg.go | 6 +++++- |
| 19 | 2 files changed, 8 insertions(+), 2 deletions(-) |
| 20 | |
| 21 | diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go |
| 22 | index c36a12e..5d31718 100644 |
| 23 | --- a/src/cmd/dist/build.go |
| 24 | +++ b/src/cmd/dist/build.go |
| 25 | @@ -264,7 +264,9 @@ func xinit() { |
| 26 | } |
| 27 | xatexit(rmworkdir) |
| 28 | |
| 29 | - tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) |
| 30 | + if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" { |
| 31 | + tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch) |
| 32 | + } |
| 33 | } |
| 34 | |
| 35 | // compilerEnv returns a map from "goos/goarch" to the |
| 36 | diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go |
| 37 | index 3257140..bb46253 100644 |
| 38 | --- a/src/cmd/go/internal/cfg/cfg.go |
| 39 | +++ b/src/cmd/go/internal/cfg/cfg.go |
| 40 | @@ -229,7 +229,11 @@ func SetGOROOT(goroot string, isTestGo bool) { |
| 41 | // This matches the initialization of ToolDir in go/build, except for |
| 42 | // using ctxt.GOROOT and the installed GOOS and GOARCH rather than the |
| 43 | // GOROOT, GOOS, and GOARCH reported by the runtime package. |
| 44 | - build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH) |
| 45 | + if s := os.Getenv("GOTOOLDIR"); s != "" { |
| 46 | + build.ToolDir = filepath.Clean(s) |
| 47 | + } else { |
| 48 | + build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH) |
| 49 | + } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | -- |
| 54 | 2.30.2 |
| 55 | |