unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#51981] (no subject)
@ 2021-11-19 19:59 Collin J. Doering
  2021-11-19 20:37 ` [bug#51981] [PATCH 1/1] build: Fix cross compilation for go-build-system Collin J. Doering
  2022-05-14  7:23 ` [bug#51981] [PATCH 0/1] Fix cross-compilation of packages that use go-build-system Maxime Devos
  0 siblings, 2 replies; 3+ messages in thread
From: Collin J. Doering @ 2021-11-19 19:59 UTC (permalink / raw)
  To: 51981

Hi all,

This patch resolves an issue I discovered when attempting to cross-compile packages that use the go-build-system.

Namely, prior to this patch, running 'guix build --target=arm-unknown-linux-gnueabihf <go-package>' where '<go-package>' is some package that uses to go-build-system (for example, 'fzf'), would result in the following error in the build log:

--8<---------------cut here---------------start------------->8---
go install: cannot install cross-compiled binaries when GOBIN is set
Building 'github.com/junegunn/fzf' failed.
Here are the results of `go env`:
GO111MODULE="off"
GOARCH="arm"
GOBIN="/gnu/store/8xcs9vna6zyl814j78raynccm7mqqk0h-fzf-0.25.0/bin"
GOCACHE="/tmp/go-cache"
GOENV="/homeless-shelter/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/guix-build-fzf-0.25.0.drv-0"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/gnu/store/y5rwacd5l4q26pxis28wsmswj2603hkw-go-1.14.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/gnu/store/y5rwacd5l4q26pxis28wsmswj2603hkw-go-1.14.15/pkg/tool/linux_amd64"
GCCGO="gccgo"
GOARM="7"
AR="ar"
CC="/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/bin/gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -marm -fmessage-length=0 -fdebug-prefix-map=/tmp/guix-build-fzf-0.25.0.drv-0/go-build219362912=/tmp/go-build -gno-record-gcc-switches"
command "go" "install" "-v" "-x" "-ldflags=-s -w" "github.com/junegunn/fzf" failed with status 1
--8<---------------cut here---------------end--------------->8---

The important bit is the first line, which indicates that 'GOBIN' cannot be set when cross-compiling. This has been the case in go from what I can tell for numerous years (atleast 2019).

This patch removes the setting of 'GOBIN' and adjusts the go-build-systems build function to us 'go build' instead of 'go install'.

Collin J. Doering (1):
  build: Fix cross compilation for go-build-system

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

-- 
2.33.1

-- 
Collin J. Doering

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#51981] [PATCH 1/1] build: Fix cross compilation for go-build-system
  2021-11-19 19:59 [bug#51981] (no subject) Collin J. Doering
@ 2021-11-19 20:37 ` Collin J. Doering
  2022-05-14  7:23 ` [bug#51981] [PATCH 0/1] Fix cross-compilation of packages that use go-build-system Maxime Devos
  1 sibling, 0 replies; 3+ messages in thread
From: Collin J. Doering @ 2021-11-19 20:37 UTC (permalink / raw)
  To: 51981

---
 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




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#51981] [PATCH 0/1] Fix cross-compilation of packages that use go-build-system
  2021-11-19 19:59 [bug#51981] (no subject) Collin J. Doering
  2021-11-19 20:37 ` [bug#51981] [PATCH 1/1] build: Fix cross compilation for go-build-system Collin J. Doering
@ 2022-05-14  7:23 ` Maxime Devos
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Devos @ 2022-05-14  7:23 UTC (permalink / raw)
  To: 51981

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]


> [PATCH 1/1] build: Fix cross compilation for go-build-system
Nice.

> +              ;; 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"))))

Maybe add a comment on why the simpler "GOBIN" isn't used instead, such
that it won't be incorrectly simplified in the future.  I'm not sure if
this is correct though, what if the name of the binary differs from the
package name?  Or was if the go package has multiple binaries?


I found it at <https://patches.guix-patches.cbaines.net/project/guix-patches/patch/877dd36fvc.fsf@rekahsoft.ca/>,
but it doesn't seem to be in data.guix-patches.cbaines.net <https://data.guix-patches.cbaines.net/compare?base_commit=256c3e714a459af6db2343c9120c7180c5a14462&target_commit=9630c40d89c8f778c4961b49e30275f35a45948c> anymore,
maybe you could resend the patch as a v2?

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-14  7:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 19:59 [bug#51981] (no subject) Collin J. Doering
2021-11-19 20:37 ` [bug#51981] [PATCH 1/1] build: Fix cross compilation for go-build-system Collin J. Doering
2022-05-14  7:23 ` [bug#51981] [PATCH 0/1] Fix cross-compilation of packages that use go-build-system Maxime Devos

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).