blob: 30068d8e7493624b767e0778aec632781bbc076b [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 7e0136a882757da0a374ab8592209586eced0e1c Mon Sep 17 00:00:00 2001
Andrew Geissler595f6302022-01-24 19:11:47 +00002From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Wed, 23 Oct 2019 21:15:37 +0430
4Subject: [PATCH] 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---
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
Patrick Williams92b42cb2022-09-03 06:53:57 -050021diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
22index 7c44c4a..3024d0c 100644
Andrew Geissler595f6302022-01-24 19:11:47 +000023--- a/src/cmd/dist/build.go
24+++ b/src/cmd/dist/build.go
Patrick Williams92b42cb2022-09-03 06:53:57 -050025@@ -264,7 +264,9 @@ func xinit() {
Andrew Geissler595f6302022-01-24 19:11:47 +000026 }
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
Patrick Williams92b42cb2022-09-03 06:53:57 -050036diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
37index c6ddfe5..605adb1 100644
Andrew Geissler595f6302022-01-24 19:11:47 +000038--- a/src/cmd/go/internal/cfg/cfg.go
39+++ b/src/cmd/go/internal/cfg/cfg.go
Patrick Williams92b42cb2022-09-03 06:53:57 -050040@@ -162,7 +162,11 @@ func SetGOROOT(goroot string) {
Andrew Geissler595f6302022-01-24 19:11:47 +000041 // variables. This matches the initialization of ToolDir in
Patrick Williams92b42cb2022-09-03 06:53:57 -050042 // go/build, except for using BuildContext.GOROOT rather than
Andrew Geissler595f6302022-01-24 19:11:47 +000043 // runtime.GOROOT.
Patrick Williams92b42cb2022-09-03 06:53:57 -050044- build.ToolDir = filepath.Join(goroot, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
Andrew Geissler595f6302022-01-24 19:11:47 +000045+ if s := os.Getenv("GOTOOLDIR"); s != "" {
46+ build.ToolDir = filepath.Clean(s)
47+ } else {
Patrick Williams92b42cb2022-09-03 06:53:57 -050048+ build.ToolDir = filepath.Join(goroot, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
Andrew Geissler595f6302022-01-24 19:11:47 +000049+ }
50 }
Patrick Williams92b42cb2022-09-03 06:53:57 -050051 }
Andrew Geissler595f6302022-01-24 19:11:47 +000052