Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory #16082

Closed
vanloswang opened this issue Jun 16, 2016 · 7 comments
Closed

Comments

@vanloswang
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6.2 linux/arm64
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="arm64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="arm64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH=""
    GORACE=""
    GOROOT="/usr/lib/golang"
    GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_arm64"
    GO15VENDOREXPERIMENT="1"
    CC="gcc"
    GOGCCFLAGS="-fPIC -pthread -fmessage-length=0"
    CXX="g++"
    CGO_ENABLED="1"
  3. What did you do?
    Just build openshift origin 1.1.6 on aarch64 platform on CentOS aarch64 edition. failed with below error:
    /usr/lib/golang/pkg/tool/linux_arm64/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory

My device have only 2G memory and no swap space.

  1. What did you expect to see?
    compile ok.
  2. What did you see instead?
    compile failed.
@vanloswang
Copy link
Author

compile k8s and give the same error as follow:
Go version: go version go1.6.2 linux/arm64
+++ [0616 15:45:17] Building go targets for linux/arm64:
cmd/hyperkube
cmd/kube-apiserver
*# k8s.io/kubernetes/cmd/hyperkube
/usr/lib/golang/pkg/tool/linux_arm64/link: running aarch64-linux-gnu-gcc failed: fork/exec /usr/bin/aarch64-linux-gnu-gcc: cannot allocate memory

!!! Error in /home/ws/rpmbuild/BUILD/ose-738b7603b042dcda7a5ba419ab0e7f40a617080c/hack/lib/golang.sh:423
'go build -o "${outfile}" "${goflags[@]:+${goflags[@]}}" -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') ${goldflags}" "${binary}"' exited with status 2
Call stack:
1: /home/ws/rpmbuild/BUILD/ose-738b7603b042dcda7a5ba419ab0e7f40a617080c/hack/lib/golang.sh:423 kube::golang::build_binaries_for_platform(...)
2: /home/ws/rpmbuild/BUILD/ose-738b7603b042dcda7a5ba419ab0e7f40a617080c/hack/lib/golang.sh:576 kube::golang::build_binaries(...)
3: hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/ws/rpmbuild/BUILD/ose-738b7603b042dcda7a5ba419ab0e7f40a617080c/hack/lib/golang.sh:496
'kube::golang::build_binaries "$@"' exited with status 1
Call stack:
1: /home/ws/rpmbuild/BUILD/ose-738b7603b042dcda7a5ba419ab0e7f40a617080c/hack/lib/golang.sh:496 kube::golang::build_binaries(...)
2: hack/build-go.sh:26 main(...)
Exiting with status 1
error: Bad exit status from /var/tmp/rpm-tmp.OphhgA (%build)

RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.OphhgA (%build)

@ianlancetaylor
Copy link
Contributor

I don't see any way for us to fix this. Your system is out of memory. It happens.

You may be able to make the build succeed by setting the environment variable GOMAXPROCS to 1.

Closing because I don't think there is anything to do. Please feel free to comment if you disagree.

@vanloswang
Copy link
Author

@ianlancetaylor On RPI3B arm32 os, there is only 1G memory and k8s will compile ok on it. But on Pine64 with 2G memory and aarch64 os, k8s compile failed. After I trace it, I found that as follow:
root 5983 3.4 2.1 265380 44528 pts/0 Sl+ 11:41 0:26 go install -ldflags -X github.com/openshift/origin/pkg/version.majorFromGit 1 -X github.com/openshift/orig
root 7762 97.0 76.3 1559592 1554580 pts/0 Rl+ 11:51 2:40 /usr/lib/golang/pkg/tool/linux_arm64/link -o /tmp/go-build013022721/github.com/openshift/origin/cmd/opensh......

When the compile proccess reach here, the memory is linear decreasing. It is so obvious and strange.

Setting the environment variable GOMAXPROCS to 1 is not working for me.

@mikioh mikioh changed the title /usr/lib/golang/pkg/tool/linux_arm64/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory cmd/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory Jun 17, 2016
@maruel
Copy link
Contributor

maruel commented Sep 19, 2016

Should https://github.com/golang/go/wiki/GoArm#swap be updated? It hints that 256Mb of RAM with 512Mb of swap is sufficient.

@minux
Copy link
Member

minux commented Sep 19, 2016

On Sep 19, 2016 9:45 AM, "M-A" notifications@github.com wrote:

Should https://github.com/golang/go/wiki/GoArm#swap be updated? It hints
that 256Mb of RAM with 512Mb of swap is sufficient.

That's the requirement for building Go from source, not the minimum
requirement for building arbitrary Go programs.

@maruel
Copy link
Contributor

maruel commented Sep 20, 2016

Oh you are right this issue is about build a random project; I got this error from building the toolchain from sources.

@davecheney
Copy link
Contributor

The minimum for building Go from source is 512mb per core for 32bit system,
1/3rd more for 64bit.

Please update the wiki page.

On Tue, 20 Sep 2016, 10:55 M-A notifications@github.com wrote:

Oh you are right this issue is about build a random project; I got this
error from building the toolchain from sources.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#16082 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAcA2qcUE2aoS_qqXck4lMaDf2o6LT0ks5qry8bgaJpZM4I3bNe
.

@golang golang locked and limited conversation to collaborators Sep 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants