0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 28ada8896b76d620240bafc22aa395071d601482 Mon Sep 17 00:00:00 2001
  2. From: Alex Kube <alexander.j.kube@gmail.com>
  3. Date: Wed, 23 Oct 2019 21:15:37 +0430
  4. Subject: [PATCH 3/9] cmd/go: Allow GOTOOLDIR to be overridden in the environment
  5. to allow for split host/target build roots
  6. Adapted to Go 1.13 from patches originally submitted to
  7. the meta/recipes-devtools/go tree by
  8. Matt Madison <matt@madison.systems>.
  9. Upstream-Status: Inappropriate [OE specific]
  10. Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
  11. ---
  12. src/cmd/dist/build.go | 4 +++-
  13. src/cmd/go/internal/cfg/cfg.go | 6 +++++-
  14. 2 files changed, 8 insertions(+), 2 deletions(-)
  15. diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
  16. index 9e50311..683ca6f 100644
  17. --- a/src/cmd/dist/build.go
  18. +++ b/src/cmd/dist/build.go
  19. @@ -244,7 +244,9 @@ func xinit() {
  20. workdir = xworkdir()
  21. xatexit(rmworkdir)
  22. - tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
  23. + if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
  24. + tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
  25. + }
  26. }
  27. // compilerEnv returns a map from "goos/goarch" to the
  28. diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
  29. index a3277a6..db96350 100644
  30. --- a/src/cmd/go/internal/cfg/cfg.go
  31. +++ b/src/cmd/go/internal/cfg/cfg.go
  32. @@ -60,7 +60,11 @@ func defaultContext() build.Context {
  33. // variables. This matches the initialization of ToolDir in
  34. // go/build, except for using ctxt.GOROOT rather than
  35. // runtime.GOROOT.
  36. - build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
  37. + if s := os.Getenv("GOTOOLDIR"); s != "" {
  38. + build.ToolDir = filepath.Clean(s)
  39. + } else {
  40. + build.ToolDir = filepath.Join(ctxt.GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
  41. + }
  42. }
  43. ctxt.GOPATH = envOr("GOPATH", ctxt.GOPATH)
  44. --
  45. 2.17.1 (Apple Git-112)