constabulary / gb

gb, the project based build tool for Go
https://getgb.io/
MIT License
2.15k stars 150 forks source link

gb build fails on centos7 with linking error #728

Open behzad-mozaffari opened 6 years ago

behzad-mozaffari commented 6 years ago

On a centos 7 machine running go 1.9. gb build generates the following error after compilation is finished.

/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-237740002/000000.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status

gb build, runs on the same project in windows and mac with not issues. On windows setting GOOS and GOARCH to linux results in a binary but on mac the following error is shown missing function body errors for internal package

# internal/poll
fd_mutex.go:194:6: missing function body for "runtime_Semacquire"
fd_mutex.go:195:6: missing function body for "runtime_Semrelease"
fd_poll_runtime.go:17:6: missing function body for "runtimeNano"
fd_poll_runtime.go:19:6: missing function body for "runtime_pollServerInit"
fd_poll_runtime.go:20:6: missing function body for "runtime_pollServerDescriptor"
fd_poll_runtime.go:21:6: missing function body for "runtime_pollOpen"
fd_poll_runtime.go:22:6: missing function body for "runtime_pollClose"
fd_poll_runtime.go:23:6: missing function body for "runtime_pollWait"
fd_poll_runtime.go:24:6: missing function body for "runtime_pollWaitCanceled"
fd_poll_runtime.go:25:6: missing function body for "runtime_pollReset"
fd_poll_runtime.go:25:6: too many errors

This doesn't happen in a simple single file project with no dependecies.

excavador commented 6 years ago

I see the same problem if I use

GOOS=linux GOARCH=amd64 gb build cmd/...

on OSX machine

davecheney commented 6 years ago

Hello,

It looks like your using the go tool not gb. You may need to raise this issue elsewhere.

If the problem is with gb, please do the following.

  1. Make sure go is properly installed, check for duplicate versions, unset GOROOT, etc
  2. Make sure gb is built with the version of go installed on your machine. If you’ve upgraded go, even if it’s in the same spot, rebuild gb
  3. If the issue persists please open a new issue, referencing this one if required.

On 19 Oct 2017, at 17:31, Jithin James notifications@github.com wrote:

Facing similar issue here on Centos 7:

[root@home runc]# cat /etc/centos-release CentOS Linux release 7.4.1708 (Core)

[root@home runc]# go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/root/buildah" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build173567046=/tmp/go-build -gno-record-gcc-switches" 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"

[root@home runc]# make go build -buildmode=pie -ldflags "-X main.gitCommit="c05f6368afaf7f720c10b1207a51e40fccf05295" -X main.version=1.0.0-rc4+dev " -tags "seccomp" -o runc .

internal/poll

/usr/local/go/src/internal/poll/fd_mutex.go:194:6: missing function body for "runtime_Semacquire" /usr/local/go/src/internal/poll/fd_mutex.go:195:6: missing function body for "runtime_Semrelease" /usr/local/go/src/internal/poll/fd_poll_runtime.go:17:6: missing function body for "runtimeNano" /usr/local/go/src/internal/poll/fd_poll_runtime.go:19:6: missing function body for "runtime_pollServerInit" /usr/local/go/src/internal/poll/fd_poll_runtime.go:20:6: missing function body for "runtime_pollServerDescriptor" /usr/local/go/src/internal/poll/fd_poll_runtime.go:21:6: missing function body for "runtime_pollOpen" /usr/local/go/src/internal/poll/fd_poll_runtime.go:22:6: missing function body for "runtime_pollClose" /usr/local/go/src/internal/poll/fd_poll_runtime.go:23:6: missing function body for "runtime_pollWait" /usr/local/go/src/internal/poll/fd_poll_runtime.go:24:6: missing function body for "runtime_pollWaitCanceled" /usr/local/go/src/internal/poll/fd_poll_runtime.go:25:6: missing function body for "runtime_pollReset" /usr/local/go/src/internal/poll/fd_poll_runtime.go:25:6: too many errors make: *** [runc] Error 2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

jithinjk commented 6 years ago

@davecheney Sorry it was a different issue meant for a different project.

behzad-mozaffari commented 6 years ago

I can build the project by setting CGO_ENABLED=0 and GOPATH={project}:{project}/vendor and running go install. I couldn't get gb to pass through the CGO_ENABLED parameter.

davecheney commented 6 years ago

Gb does not support cross compilation with cgo enabled.

On 19 Oct 2017, at 21:59, behzad-mozaffari notifications@github.com wrote:

I had a freshly installed go + gb. GOROOT wasn't set. I wasn't using go tool directly. The error is the result of running gb build. I can build the project by setting CGO_ENABLED=0 and GOPATH={project}:{project}/vendor and running go install. I couldn't get gb to pass through the CGO_ENABLED parameter.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

excavador commented 6 years ago

I can not stable reproduce the problem, but time-to-time receive problem on my OSX with cross-compilation to linux WITHOUT cgo. I pretty sure what only gb used (because we build by GNU Make, where only gb used)