Subject: [bug#51981] (no subject)

From: "Collin J. Doering" <[email-masked]>
Date: Fri, 19 Nov 2021 14:59:07 -0500

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