GNU bug report logs -
#51981
[PATCH 0/1] Fix cross-compilation of packages that use go-build-system
Previous Next
To reply to this bug, email your comments to 51981 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#51981
; Package
guix-patches
.
(Fri, 19 Nov 2021 20:18:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Collin J. Doering" <collin <at> rekahsoft.ca>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
Your message did not contain a Subject field. They are recommended and
useful because the title of a $gBug is determined using this field.
Please remember to include a Subject field in your messages in future.
(Fri, 19 Nov 2021 20:18:01 GMT) Full text and rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#51981
; Package
guix-patches
.
(Fri, 19 Nov 2021 20:39:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 51981 <at> debbugs.gnu.org (full text, mbox):
---
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
Changed bug title to '[PATCH 0/1] Fix cross-compilation of packages that use go-build-system' from '(no subject)'
Request was from
"Collin J. Doering" <collin <at> rekahsoft.ca>
to
control <at> debbugs.gnu.org
.
(Fri, 19 Nov 2021 20:49:01 GMT)
Full text and
rfc822 format available.
Added tag(s) patch.
Request was from
"Collin J. Doering" <collin <at> rekahsoft.ca>
to
control <at> debbugs.gnu.org
.
(Fri, 19 Nov 2021 21:17:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#51981
; Package
guix-patches
.
(Sat, 14 May 2022 07:24:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 51981 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> [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 <at> 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.
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 3 years and 30 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.