Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

llvm/clang compile error with Memory exhausted

Tags:

clang

I am trying to build the latest llvm/clang code on my ubuntu 14.04 vm, which has 2GB memory.

What I did is a normal configure/make procedure, without any parameters to these two commands.

at last, I have the following error:

llvm[4]: Linking Debug+Asserts executable clang
/usr/bin/ld: failed to set dynamic section sizes: Memory exhausted
collect2: error: ld returned 1 exit status
make[4]: *** [/home/alex/Downloads/llvm_build/Debug+Asserts/bin/clang] Error 1
make[4]: Leaving directory /home/alex/Downloads/llvm_build/tools/clang/tools/driver' make[3]: *** [driver/.makeall] Error 2 make[3]: Leaving directory/home/alex/Downloads/llvm_build/tools/clang/tools'
make[2]: * [all] Error 1
make[2]: Leaving directory /home/alex/Downloads/llvm_build/tools/clang' make[1]: *** [clang/.makeall] Error 2 make[1]: Leaving directory/home/alex/Downloads/llvm_build/tools'
make: *** [all] Error 1

Does anyone know how to resolve this?

like image 636
Alex Avatar asked Aug 08 '14 06:08

Alex


People also ask

How much space does Clang take?

Note that Debug builds require a lot of time and disk space. An LLVM-only build will need about 1-3 GB of space. A full build of LLVM and Clang will need around 15-20 GB of disk space.

Is LLVM same as Clang?

LLVM is a backend compiler meant to build compilers on top of it. It deals with optimizations and production of code adapted to the target architecture. CLang is a front end which parses C, C++ and Objective C code and translates it into a representation suitable for LLVM.

What is LLVM in Clang?

The combination of Clang front-end and LLVM back-end is called Clang/LLVM or simply Clang. The name LLVM was originally an initialism for Low Level Virtual Machine. However, the LLVM project evolved into an umbrella project that has little relationship to what most current developers think of as a virtual machine.

Does LLVM include Clang?

Clang is released as part of regular LLVM releases. You can download the release versions from https://llvm.org/releases/. Clang is also provided in all major BSD or GNU/Linux distributions as part of their respective packaging systems. From Xcode 4.2, Clang is the default compiler for Mac OS X.


2 Answers

You need to do one of the following:

  1. Add more RAM to your VM, or
  2. Use gold instead of ld as a linker, or
  3. Build Release(-DCMAKE_BUILD_TYPE=Release), not Debug build
like image 139
Anton Korobeynikov Avatar answered Nov 13 '22 11:11

Anton Korobeynikov


Another consideration: If you have Make running parallel jobs (e.g., make -j8), the concurrently executing jobs may require too much memory.

like image 30
Christian Convey Avatar answered Nov 13 '22 11:11

Christian Convey