Search code examples
out-of-memoryclangld

Compiling clang on a 32-bit system fails because of insufficient virtual memory


I am trying to compile clang 3.9 on a 32 bit scientific linux.

The compilation process fails at 93% with the following error:

[ 93%] Linking CXX executable ../../bin/clang
/lib/ld-linux.so.2: could not read symbols: Memory exhausted
collect2: error: ld returned 1 exit status
gmake[2]: *** [bin/clang-3.9] Error 1
gmake[1]: *** [tools/driver/CMakeFiles/clang.dir/all]
Error 2 gmake: *** [all] Error 2

My machine has 8GB of RAM, and looking with top the memory usage evolution during linkage, I see that it fails after 3GB, which is the process virtual memory limit on 32bit linux.

I saw that for a quite similar problem, someone advised to compile the Release version, so I tried, but it fails with the same type of error (even if apparently going a little further):

[ 93%] Linking CXX executable ../../bin/clang
collect2: error: ld terminated with signal 11 [Segmentation fault]
/opt/rh/devtoolset-2/root/usr/libexec/gcc/i686-redhat-linux/4.8.2/ld: can not read symbols: Memory exhausted
gmake[2]: *** [bin/clang-3.9] Error 1
gmake[2]: *** Deleting file `bin/clang-3.9'
gmake[1]: *** [tools/driver/CMakeFiles/clang.dir/all] Error 2
gmake: *** [all] Error 2

Any ideas?


Solution

  • In GCC the following flags help ld in limited RAM environment:

    -Wl,--no-keep-memory -Wl,--reduce-memory-overheads