blob: c3ccffc3e95f6e27e6144bf2794e09b2c2f3f5bb [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001From 8512964c0bfdfc3c9c3805743ea7de551a1d476a Mon Sep 17 00:00:00 2001
2From: 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
Andrew Geissler595f6302022-01-24 19:11:47 +000021--- a/src/cmd/dist/build.go
22+++ b/src/cmd/dist/build.go
Patrick Williams03907ee2022-05-01 06:28:52 -050023@@ -251,7 +251,9 @@ func xinit() {
Andrew Geissler595f6302022-01-24 19:11:47 +000024 }
25 xatexit(rmworkdir)
26
27- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
28+ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
29+ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
30+ }
31 }
32
33 // compilerEnv returns a map from "goos/goarch" to the
Andrew Geissler595f6302022-01-24 19:11:47 +000034--- a/src/cmd/go/internal/cfg/cfg.go
35+++ b/src/cmd/go/internal/cfg/cfg.go
Patrick Williams03907ee2022-05-01 06:28:52 -050036@@ -76,7 +76,11 @@ func defaultContext() build.Context {
Andrew Geissler595f6302022-01-24 19:11:47 +000037 // variables. This matches the initialization of ToolDir in
38 // go/build, except for using ctxt.GOROOT rather than
39 // runtime.GOROOT.
40- build.ToolDir = filepath.Join(ctxt.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(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
45+ }
46 }
47
Patrick Williams03907ee2022-05-01 06:28:52 -050048 ctxt.GOPATH = envOr("GOPATH", gopath(ctxt))