Ld Failed by Low Memory Amount

Error:ld terminated with signal 9 killed

I was using Yocto to build an image including Qt. While Building the image, an error message pop up and stop the bitbake process. When I traced back the log, it shows error occurred at QtWebEngine.

How it looks like

Well, go to google it. It is pretty straight forward that it is an error due to low memory both in RAM and swap. The laptop was running on 4G Ram and 2G swap space. Then I ran top command on another terminal and rerun the bitbake. ld took RAM from 1% to 85% quickly, and it started to use swap file then, yes it terminated with error.

It is very clear that ld consumes large amount of memory and halt machine until kernel send kill signal to terminate ld process.

Solution

Well, since the problem is caused by memory. It is easy to pop up some solutions.

  • Increase RAM

    The brute force way, add my laptop RAM up.
    Honestly, RAM’s price is cheap less than a decent diner. I added my own desktop up to 48G RAM. However, this is not work laptop, I even can’t pay my own cash to upgrade it.

  • Increase swap size

    Increase swap file size is another good method. Since Memory is not enough, then kernel will use swap to cache jobs.

    1
    2
    3
    4
    5
    6
    #create new swap file 4098x1M size filled with zeros
    sudo dd if=/dev/zero of=/extraswap bs=1M count=4098
    #setup file as a swap file
    sudo mkswap /extraswap
    #enable created swapfile
    sudo swapon /extraswap

    Credit by Increase your available swap

    Even I increase the swap, it just took longer to break. So I go to try the third one.

  • Reduce Parallel works in Yocto

    Actually I realize that Yocto Bitbake runs in 4 threads at the same time. So I go to conf/local.conf , Search the BB_NUMBER_THREADS and change the parallel work job to single thread.

    1
    2
    3
    4
    #BB_NUMBER_THREADS ?= "${@oe.utils.cpu_count()}"
    #PARALLEL_MAKE ?= "-j ${@oe.utils.cpu_count()}"
    BB_NUMBER_THREADS ?= "1"
    PARALLEL_MAKE ?= "-j 1"

    After this change, it is much slower but it is succesful build without error.


This is weird error. It is not a bug, but it’s just how things have turned out to be these days. Buy more Power and more memory for you machine.
Well, it is good to know.