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

Cargo build runs out of memory and crashes when linking multiple workspace members #9735

Closed
AidaPaul opened this issue Jul 27, 2021 · 1 comment
Labels
C-bug Category: bug

Comments

@AidaPaul
Copy link

AidaPaul commented Jul 27, 2021

Problem
I have a project which is a workspace consisting of four members, and when I run cargo build on a 1GB ram kunbus box, when it comes to linking eventually cargo will run out of memory and crash.

Running cargo build --jobs 1 is a workaround, and then linking passes just fine, but it's obviously very very slow on the compiling part.

Steps

  1. Create a workspace with multiple members, and make each member relatively memory-heavy to build.
  2. Run cargo build on low memory system and observe a memory climb until the whole process crashes with error:
error: linking with `cc` failed: exit status: 1
[snip]
= note: collect2: fatal error: ld terminated with signal 9 [Killed]
  1. Run cargo build --jobs 1 and observe linking passing just fine.

Possible Solution(s)
Ideally I would like it to keep using all the jobs it seems sensible to compile, and then do some smartness around linking to see if there is enough memory to actually do the jobs, and if not, reduce jobs to passable amount (or even just 1 for simplicity’s sake).

Notes

Output of cargo version:

cargo 1.53.0 (4369396 2021-04-27)
Tried with toolchains:
nightly-armv7-unknown-linux-gnueabihf
stable-armv7-unknown-linux-gnueabihf
Uname -a:
Linux RevPi47515 4.19.95-rt38-v7 #1 SMP PREEMPT RT Tue, 22 Jun 2021 14:13:31 +0000 armv7l GNU/Linux
Hardware in question: https://shop.pimoroni.com/products/revpi-core-3

Processor | Broadcom BCM2837
Number of cores | 4
Clock rate | 1.2 GHz
RAM | 1 GB
eMMC flash memory | 4 GB

No swap. Setting swap to 100mb only gets that filled up and then crash.

@AidaPaul AidaPaul added the C-bug Category: bug label Jul 27, 2021
@ehuss
Copy link
Contributor

ehuss commented Aug 4, 2021

Thanks for the report! I believe this is a duplicate of #9157, so closing in favor of that.

@ehuss ehuss closed this as completed Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants