'Building LLVM eats up all the RAM
I have been trying to install LLVM on my system [i7 + 16GB RAM]. I have been following this tutorial : LLVM Install. But in building, it eats up all the RAM and the terminal closes automatically. Is there any way to solve this?
Thanks.
Solution 1:[1]
The resources consumed during build can depend on various factors:
- Number of build targets that you are building. In general you should be able to skip a bunch of build targets (compiler-rt, libcxx etc)
- The type of binaries that will be generated. I mean, shared vs. static. Enabling shared libraries (
BUILD_SHARED_LIBS:ON
) will consume way less memory. - The type of optimization flag. Debug, Release, RelWithDebInfo will also have an effect. The Debug build will have larger binary size so it may consume more memory during the link step. But the build time will be faster as few optimizations are enabled. Release build may consume less RAM during the link step.
- Number of threads
-jN
TLDR for reducing RAM pressure:
- Enable shared libraries
- Use Release builds
- Keep number of parallel threads low
-j4
etc. Using-j1
may take long time to build. - Skip building as many libraries as you can. This may not be trivial as it requires spending time with the CMakeCache.txt file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | A. K. |