Subject: [bug#51981] [PATCH 1/1] build: Fix cross compilation for go-build-system

From: "Collin J. Doering" <[email-masked]>
Date: Fri, 19 Nov 2021 15:37:34 -0500

---
 guix/build/go-build-system.scm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 4768ee8562..f36e98f47a 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -148,7 +148,6 @@ (define* (setup-go-environment #:key inputs outputs goos goarch #:allow-other-ke
   ;; currently support modules, so turn modules off to continue using the old
   ;; GOPATH behavior.
   (setenv "GO111MODULE" "off")
-  (setenv "GOBIN" (string-append (assoc-ref outputs "out") "/bin"))
 
   ;; Make sure we're building for the correct architecture and OS targets
   ;; that Guix targets.
@@ -234,14 +233,19 @@ (define (go-inputs inputs)
                 (_ #f))
               inputs))))
 
-(define* (build #:key import-path build-flags #:allow-other-keys)
+(define* (build #:key outputs import-path build-flags #:allow-other-keys)
   "Build the package named by IMPORT-PATH."
   (with-throw-handler
     #t
     (lambda _
-      (apply invoke "go" "install"
+      (apply invoke "go" "build"
               "-v" ; print the name of packages as they are compiled
               "-x" ; print each command as it is invoked
+              ;; Set the output path for the build
+              (string-append "-o="
+                (assoc-ref outputs "out") "/bin/"
+                (package-name->name+version
+                  (strip-store-file-name (assoc-ref outputs "out"))))
               ;; Respectively, strip the symbol table and debug
               ;; information, and the DWARF symbol table.
               "-ldflags=-s -w"
-- 
2.33.1

-- 
Collin J. Doering

http://rekahsoft.ca
http://blog.rekahsoft.ca
http://git.rekahsoft.ca