Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the linker terminating on me? when i build CLang

Tags:

gcc

linker

Your virtual machine does not have enough memory to perform the linking phase. Linking is typical the most memory intensive part of a build since it's where all the object code comes together and is operated on as a whole.

If you can allocate more RAM to the VM then do that. Alternatively you could increase the amount of swap space. I am not that familiar with VMs but I imagine the virtual hard drive you set-up will have a swap partition. If you can make that bigger or allocate a second swap partition that would help.

Increasing the RAM, if only for the duration of your build, is the easiest thing to do though.


Also got the same issue and solved by doing following steps (It is memory issue only) -

  1. Checks current swap space by running free command (It must be around 10GB.).
  2. Checks the swap partition

    sudo fdisk -l
    /dev/hda8       none            swap    sw              0       0
    
  3. Make swap space and enable it.

    sudo swapoff -a
    sudo /sbin/mkswap /dev/hda8
    sudo swapon -a
    

If your swap disk size is not enough you would like to create swap file and use it.

  1. Create swap file.

    sudo fallocate -l 10g /mnt/10GB.swap
    sudo chmod 600 /mnt/10GB.swap
    

    OR

    sudo dd if=/dev/zero of=/mnt/10GB.swap bs=1024 count=10485760
    sudo chmod 600 /mnt/10GB.swap
    
  2. Mount swap file.

    sudo mkswap /mnt/10GB.swap
    
  3. Enable swap file.

    sudo swapon /mnt/10GB.swap
    

I tried with make -j1 and it works!. But it takes long time to build.


I had the same problem building on a VirtualBox system. FWIW I was building on a laptop with XP and 2GB RAM. I had to bump the virtual RAM up to 1462MB to get a successful build. Also note the recommended disk size of 8GB is not sufficient to build and install both LLVM and Clang under Ubuntu. I'd recommend at least 16GB.


I would suggest using of -l (--max-load) option instead of limiting -j in this case. Possibly helpful answer.