Cargo build fatal error - where to look for causes?

Hi,

cargo build failed to build the final executable with the following error:

error: linking with `cc` failed: exit status: 1
 |
  = note: "cc" "-m64" <snipped_large_output> 
  = note: collect2: fatal error: ld terminated with signal 9 [Killed]
          compilation terminated.

It seems like the linker ld failed but not clear why. Where should I go to find more details about such build error? for example, any cargo logs?

cargo version : 1.56.0
platform: Linux ubuntu 16.04. kernel 4.15.0

Thanks.

Signal 9, SIGKILL, is often a sign of the system OOM (out of memory) handler killing your process. There should be something in dmesg output if that is the case.

High memory usage during linking usually means you've enabled LTO, so you could try without that.

You're probably right. I tried cargo build --release and it worked. I guess the release build uses less memory as each module are smaller?

Btw, I'm not using LTO.

OK, if it works in release, then it's probably the debuginfo that's just too much memory for you to link. That could be avoided by using split-debuginfo, but I don't think that's stable on Linux yet. Another option is to reduce the amount of information, e.g. in Cargo.toml profiles:

[profile.dev]
debug = 1

(the default is 2 for dev and test builds)

1 Like

Changing to debug = 1 worked!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.