1From e1382a731a726293e30901038c6870fa77ef6095 Mon Sep 17 00:00:00 2001
2From: Angelo Compagnucci <angelo@amarulasolutions.com>
3Date: Tue, 8 May 2018 16:08:44 +0200
4Subject: [PATCH] build.go: explicit option for crosscompilation
5
6Actually if GOHOSTOS == GOOS || GOHOSTARCH == GOARCH the go build system
7assume it's not cross compiling and uses the same toolchain also for the
8bootstrap.  This is a problem in case the cross compilation mandates a
9different toolchain for bootstrap and target.  This patch adds
10GO_ASSUME_CROSSCOMPILING varible to assure that in case of cross
11compilation CC_FOR_TARGET can be different from CC.
12
13Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
14Signed-off-by: Anisse Astier <anisse@astier.eu>
15---
16 src/cmd/dist/build.go | 3 ++-
17 1 file changed, 2 insertions(+), 1 deletion(-)
18
19diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
20index 99d1db5..eb4097f 100644
21--- a/src/cmd/dist/build.go
22+++ b/src/cmd/dist/build.go
23@@ -252,12 +252,13 @@ func xinit() {
24 // $CC_FOR_goos_goarch, if set, applies only to goos/goarch.
25 func compilerEnv(envName, def string) map[string]string {
26 	m := map[string]string{"": def}
27+	crosscompiling := os.Getenv("GO_ASSUME_CROSSCOMPILING")
28
29 	if env := os.Getenv(envName); env != "" {
30 		m[""] = env
31 	}
32 	if env := os.Getenv(envName + "_FOR_TARGET"); env != "" {
33-		if gohostos != goos || gohostarch != goarch {
34+		if gohostos != goos || gohostarch != goarch || crosscompiling == "1" {
35 			m[gohostos+"/"+gohostarch] = m[""]
36 		}
37 		m[""] = env
38--
392.7.4
40
41