1

我正在尝试使用跨平台步骤构建我的程序来重现问题:

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

在互联网上寻找解决问题的方法并没有带来任何结果。

去版本去版本去1.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"

GOROOT 目录中的 VERSION 文件 = "/usr/lib/go-1.14" 存在。

猫 /usr/lib/go-1.14/VERSION

go1.14.3

当我尝试执行手动模式时,我遇到了同样的问题:

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

我该如何解决这个问题?如何运行交叉编译?

4

0 回答 0