go version
go version go1.10.4 linux/amd64
go env
GOARCH="amd64"
GOBIN="/home/mayurw/go/bin"
GOCACHE="/home/mayurw/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mayurw/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build555451646=/tmp/go-build -gno-record-gcc-switches"
I executed the command
env GOOS=linux GOARCH=arm64 go build
it produced output as bolow
go build github.com/DataDog/zstd: build constraints exclude all Go files in ~/go/src/github.com/DataDog/zstd
I'm really not getting what error it is. Please provide solution to go cross compilation from linux to ARM architecture binaries..
You already opened this issue as https://github.com/DataDog/zstd/issues/46. Please keep the discussion there, as this isn't a bug in Go.
You can't cross-compile a package that uses CGO - that's where the error comes from. You'll see the same error if you try CGO_ENABLED=0 go build.
I honestly don't know if cross compiling with CGO is a good idea, but you could try existing workarounds like https://github.com/karalabe/xgo.
Actually, I think the error message here could be clearer. On a first scan of the package, there are no Go files with build constraints, so it can seem like the error is wrong. Only if one is aware of CGO does the error make sense.
Perhaps the error should somehow point at CGO instead of saying "build constraints exclude all Go files".
/cc @bcmills @ianlancetaylor
Hi!
Is the case I see below with go generate is the same CGO case or different?
I tried with both CGO enabled and disabled.
$ CGO_ENABLED="0" go generate
can't load package: package github.com/noobaa/noobaa-operator: build constraints exclude all Go files in ...
$ CGO_ENABLED="1" go generate
can't load package: package github.com/noobaa/noobaa-operator: build constraints exclude all Go files in ...
Thanks
@guymguym, that symptom is not this issue.
I see that the only .go source file in github.com/nooba/nooba-operator is tagged // +build tools — did you mean to pass a specific package name to go generate? (By default, go generate — like go subcommands in general — operates on the package in the current working directory.)
Hi folks
I stumbled accross this issue when trying to cross-compile a shared library implemented in go on a Linux amd64 host for a win32 target. karalabe/xgo uses docker and the machines at my hand do not support docker. However, I had success running the go compiler in wine 5.0. Maybe this helps someone else.
Most helpful comment
Actually, I think the error message here could be clearer. On a first scan of the package, there are no Go files with build constraints, so it can seem like the error is wrong. Only if one is aware of CGO does the error make sense.
Perhaps the error should somehow point at CGO instead of saying "build constraints exclude all Go files".
/cc @bcmills @ianlancetaylor