build-system/go: Fix building on host's secondary architecture.

Before when building for i686-linux on x86_64-linux GOARCH would be set
to amd64, not 386.

* guix/build-system/go.scm (go-build): Set goarch and goos to #f when
not cross-compiling.
* guix/build/go-build-system.scm (setup-go-environment): Set GOARCH
according to the calculated goarch or using GOHOSTARCH and GOOS
according to the calculated goos or using GOHOSTOS.
This commit is contained in:
Efraim Flashner 2021-10-18 14:39:58 +03:00
parent 9cda21cf20
commit 0cd912186a
No known key found for this signature in database
GPG Key ID: 41AAE7DCCA3D8351
2 changed files with 6 additions and 4 deletions

View File

@ -163,8 +163,8 @@ commit hash and its date rather than a proper release tag."
(tests? #t) (tests? #t)
(allow-go-reference? #f) (allow-go-reference? #f)
(system (%current-system)) (system (%current-system))
(goarch (first (go-target (%current-system)))) (goarch #f)
(goos (last (go-target (%current-system)))) (goos #f)
(guile #f) (guile #f)
(imported-modules %go-build-system-modules) (imported-modules %go-build-system-modules)
(modules '((guix build go-build-system) (modules '((guix build go-build-system)

View File

@ -152,8 +152,10 @@ dependencies, so it should be self-contained."
;; Make sure we're building for the correct architecture and OS targets ;; Make sure we're building for the correct architecture and OS targets
;; that Guix targets. ;; that Guix targets.
(setenv "GOARCH" goarch) (setenv "GOARCH" (or goarch
(setenv "GOOS" goos) (getenv "GOHOSTARCH")))
(setenv "GOOS" (or goos
(getenv "GOHOSTOS")))
(match goarch (match goarch
("arm" ("arm"
(setenv "GOARM" "7")) (setenv "GOARM" "7"))