How to use less memory when compiling to avoid killing the build?
Asked Answered
W

2

6

During using cc linker and cargo, I am repeatedly running into:

  = note: collect2: fatal error: ld terminated with signal 9 [Killed]
          compilation terminated.

My VM has 4 gb of ram allocated to it, 14 gb free space, and set vm.overcommit_memory = 2 (0 was tried originally), yet this error persists. This is during the installation of the Solana SDK, the component that is failing in cargo due to cc linker is only 212K large. Why is this getting killed?

Wed answered 22/4, 2022 at 1:10 Comment(0)
C
6

Be sure to make use of the --jobs parameter in cargo build and cargo test. Even high-spec machines can run out of memory while compiling parts of the Solana codebase, so restricting the number of jobs can help keep the memory usage from going over the machine's limit.

To start, you should try:

cargo build --jobs 1

If that still fails, then you'll a machine with more memory.

Cider answered 22/4, 2022 at 19:46 Comment(0)
N
0

Make sure you can run

cargo new app
cd app
cargo build

If this is failing as a baseline, I would suggest removing the VM and trying to run from WSL

Natatorium answered 22/4, 2022 at 3:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.