Old Panda
Old Panda

Reputation: 1606

collect2: fatal error: ld terminated with signal 9 [Killed]

I'm trying to build precimonious on Ubuntu 16.04.3 x64. I allocated 1GB memory for it. My file structure looks like

~
|--- llvm/
|--- precimonious/

where the llvm is on version 3.0 as mentioned at https://github.com/corvette-berkeley/precimonious#requirement. Then I followed the steps on the README but command make ended with

...
llvm[1]: Linking Debug Shared Library libLLVM-3.0.so
collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
...

I went through some answers online and they say it might because there's not enough memory to perform the link. But the memory usage is like enter image description here

The gcc version on my machine is gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) and was installed via apt-get install build-essential. This is a fresh droplet I just created on DigitalOcean btw. Any help is appreciated.

Upvotes: 23

Views: 43584

Answers (7)

4pie0
4pie0

Reputation: 29724

It's too much RAM consumed by build process. This is simplest to fix if your build command is configured to build with plenty of threads. This may simply be too much, especially if you are building on docker container. For example, if you are using CMake, then change

cmake --build cmake-out -- -j $(nproc)

to use less threads, for example only 2:

cmake --build cmake-out -- -j 2

Upvotes: 1

Nabi K.A.Z.
Nabi K.A.Z.

Reputation: 10704

The problem is the lack of RAM that others have mentioned. But instead of increasing the RAM, you can add a swap with a few simple commands below and easily solve the problem:

fallocate -l 4G ./_swap.swap
mkswap ./_swap.swap
chmod 0600 ./_swap.swap
swapon ./_swap.swap

Upvotes: 1

Dawid
Dawid

Reputation: 690

I had the same error while installing snort on the Ubuntu inside a virtual box with 2 GB of RAM. I increased the RAM to 4 GB and it worked for me.

Upvotes: 3

Rishikesh
Rishikesh

Reputation: 301

you can solve this issue by using :

 cargo run --release --verbose --jobs 1

Upvotes: 8

houssam
houssam

Reputation: 1873

I had this problem, and solved by:

  • Increase SWAP disk (8 GB working with me).
  • Increase Memory (I was on virtual machine, 8 GB).
  • You need 27 GB (LLVM 6.0.0) free disk space (check with df -h in Terminal).

Upvotes: 7

KernelPanic
KernelPanic

Reputation: 101

Sometimes system kills linker due to CPU overload. If your build is parallel, try -l option (make and ninja support it). Looks similar to your case.

To decrease system load, build release version of llvm. Linking of debug version is much more expensive.

llvm[1]: Linking Debug Shared Library libLLVM-3.0.so

Upvotes: 4

Florian Weimer
Florian Weimer

Reputation: 33704

It is memory exhaustion. The sampling interval for the memory measurement is just not small enough that it covers the exact point where the OOM killer kicks in.

Depending on the container/VM technology, you may be able to set vm.overcommit_memory=2 before the build, so that the process is not killed (but doing so actually requires more memory and swap space to get the build to complete).

Upvotes: 18

Related Questions