虚拟内存不足导致32位系统编译clang失败

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

我正在尝试在 32 位科学 linux 上编译 clang 3.9。

编译过程在 93% 处失败,出现以下错误:

[ 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

我的机器有 8GB 的​​ RAM,并且查看链接期间内存使用演变的顶部,我看到它在 3GB 后失败,这是 32 位的进程虚拟内存限制linux。

我看到对于一个非常相似的问题,有人建议编译 Release 版本,所以我尝试了,但它失败了,并出现了相同类型的错误(即使显然更进一步):

[ 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

有什么想法吗?

在 GCC 中,以下标志在有限的 RAM 环境中帮助 ld:

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