1

I'm trying to build my program using cross-platform Steps for reproducing the problem:

apt-get install golang gox
sudo gox -build-toolchain

    The toolchain build can't be parallelized because compiling a single
Go source directory can only be done for one platform at a time. Therefore,
the toolchain for each platform will be built one at a time.

--> Toolchain: plan9/386
--> Toolchain: linux/amd64
--> Toolchain: darwin/386
--> Toolchain: freebsd/arm
--> Toolchain: openbsd/amd64
--> Toolchain: openbsd/386
--> Toolchain: darwin/amd64
--> Toolchain: linux/arm
--> Toolchain: freebsd/386
--> Toolchain: windows/amd64
--> Toolchain: freebsd/amd64
--> Toolchain: windows/386
--> Toolchain: netbsd/386
--> Toolchain: netbsd/arm
--> Toolchain: linux/386
--> Toolchain: netbsd/amd64

16 errors occurred:
plan9/386: Error building 'plan9/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

linux/amd64: Error building 'linux/amd64': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

darwin/386: Error building 'darwin/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

freebsd/arm: Error building 'freebsd/arm': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

openbsd/amd64: Error building 'openbsd/amd64': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

openbsd/386: Error building 'openbsd/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

darwin/amd64: Error building 'darwin/amd64': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

linux/arm: Error building 'linux/arm': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

freebsd/386: Error building 'freebsd/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

windows/amd64: Error building 'windows/amd64': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

freebsd/amd64: Error building 'freebsd/amd64': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

windows/386: Error building 'windows/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

netbsd/386: Error building 'netbsd/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

netbsd/arm: Error building 'netbsd/arm': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

linux/386: Error building 'linux/386': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

netbsd/amd64: Error building 'netbsd/amd64': go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT


uname -a
Linux kali 5.6.0-kali2-amd64 #1 SMP Debian 5.6.14-1kali1 (2020-05-25) x86_64 GNU/Linux

Finding a solution to the problem on the Internet did not bring any results.

go version go version go1.14.3 linux/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/crank/.cache/go-build"
GOENV="/home/crank/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/crank/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.14"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.14/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build051883282=/tmp/go-build -gno-record-gcc-switches"

VERSION file in the GOROOT directory = "/usr/lib/go-1.14" is present.

cat /usr/lib/go-1.14/VERSION

go1.14.3

I get the same problems when I try in manual mode when I try to execute:

cd $(go env GOROOT)/src
sudo GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./make.bash --no-clean

Building Go cmd/dist using /usr/lib/go-1.14. (go1.14.3 linux/amd64)
go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

How can I fix this problem? How to run cross-compilation?

user5285766
  • 109
  • 2
  • 10
  • 1
    you are trying to install from sources using the repository package of your distribution. When the package are installed on your computer via the package manager, it does not create the git repository associated with those sources. Thus building the sources are failing with aforementioned message. I believe running `(cd $GOROOT && git status) || echo "not a git repository"` should display "not a git repository" –  Jun 21 '20 at 15:36
  • Actually, I tried to compile my program for the arm platform. If someone has a similar problem, then I found a simpler solution, just take and assemble it using the following command in the repository;) – user5285766 Jun 22 '20 at 16:06
  • `env GOOS=linux GOARCH=arm GOARM=5 go build` In this case, the program is built without problems for the platform you need, at least that was the case with me for arm. – user5285766 Jun 22 '20 at 16:07

0 Answers0