0001-build.go-explicit-option-for-crosscompilation.patch 1.5 KB

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