summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go-1.10/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch
blob: 818fe66700a230b2eb7c9126b5c341067a39ce5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From acd179b49f1fc8d6f7f69e569fb4a56039c725a1 Mon Sep 17 00:00:00 2001
From: Matt Madison <matt@madison.systems>
Date: Sat, 17 Feb 2018 05:24:20 -0800
Subject: [PATCH 3/9] allow GOTOOLDIR to be overridden in the environment

to allow for split host/target build roots

Upstream-Status: Inappropriate [OE specific]

Signed-off-by: Matt Madison <matt@madison.systems>
---
 src/cmd/dist/build.go          | 4 +++-
 src/cmd/go/internal/cfg/cfg.go | 6 +++++-
 src/go/build/build.go          | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index 49ed80033e..afc615b5c2 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -220,7 +220,9 @@ func xinit() {
 	workdir = xworkdir()
 	xatexit(rmworkdir)
 
-	tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
+	if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
+		tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
+	}
 }
 
 // compilerEnv returns a map from "goos/goarch" to the
diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
index 1de4f0dc79..4f6010d660 100644
--- a/src/cmd/go/internal/cfg/cfg.go
+++ b/src/cmd/go/internal/cfg/cfg.go
@@ -96,7 +96,11 @@ func init() {
 	// as the tool directory does not move based on environment variables.
 	// This matches the initialization of ToolDir in go/build,
 	// except for using GOROOT rather than runtime.GOROOT().
-	build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
+	if s := os.Getenv("GOTOOLDIR"); s != "" {
+		build.ToolDir = filepath.Clean(s)
+	} else {
+		build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
+	}
 }
 
 func findGOROOT() string {
diff --git a/src/go/build/build.go b/src/go/build/build.go
index 68fb423983..81b1b32270 100644
--- a/src/go/build/build.go
+++ b/src/go/build/build.go
@@ -1594,7 +1594,7 @@ func init() {
 }
 
 // ToolDir is the directory containing build tools.
-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
+var ToolDir = envOr("GOTOOLDIR", filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH))
 
 // IsLocalImport reports whether the import path is
 // a local import path, like ".", "..", "./foo", or "../foo".
-- 
2.14.1