Sunghyun Park via llvm-dev
2016-Oct-18 14:31 UTC
[llvm-dev] [help] How to speed up compilation?
Hi,It's first time to post question on community, so I'm not sure this is right way to ask. I'm hoping that someone can help me figure out how to speed up compilation. I'm working on LLVM 4.0 and modifying clang for my own purpose. It seems like after LLVM switches its compilation framework to cmake, the compile time is largely increased. It took almost over an hour even though I complies only certain files that I modified. (Compiles by using 'make' command without 'make clean' previous compilation) Sometimes my machine is frozen because of the compilation and dead after couple of hours. Any suggestion to speed up my compilation methodology? Appreciate your valuable time. -- Best, Sung -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161018/ff4ab23e/attachment.html>
Renato Golin via llvm-dev
2016-Oct-18 14:51 UTC
[llvm-dev] [help] How to speed up compilation?
On 18 October 2016 at 15:31, Sunghyun Park via llvm-dev <llvm-dev at lists.llvm.org> wrote:> (Compiles by using 'make' command without 'make clean' previous compilation) > Sometimes my machine is frozen because of the compilation and dead after > couple of hours.Hi Sung, That's, unfortunately, expected. If you change a top-level header (one that's included from too many other files), you can easily trigger a huge chain of dependencies and re-compile the whole thing. The freezing is due to extreme memory consumption, most likely from the linker.> Any suggestion to speed up my compilation methodology?A few hints: 1. Use "ninja" instead of "make", as it's *a lot* smarter in getting rid of non-existing dependencies. 2. Use CCache. Even if make or ninja can't detect a dependency doesn't exist, CCache can detect that the file is identical and the command line too, so it just reuses the cached copy. Very fast rebuilds! 3. Compile using shared libraries, not static linking (CMake's -DBUILD_SHARED_LIBS=True), as this will reduce re-linking all the objects into all the executables. This will reduce the number of steps and freezing. 4. Use a faster linker like "gold" or LLD (if it works for your target), as they're not just faster but use a lot less memory. This will help with freezing and speed. 5. If you have low memory, consider using CMake's -DLLVM_PARALLEL_LINK_JOBS=N, with N = min(amount of RAM in GB, CPU cores). Some link jobs can take up to 1GB. This will get rid of freezing, but will make it a bit slower. Adjust the value until it's fast enough and doesn't freeze. Hope that helps. cheers, --renato
Tim Northover via llvm-dev
2016-Oct-18 14:56 UTC
[llvm-dev] [help] How to speed up compilation?
On 18 October 2016 at 07:51, Renato Golin via llvm-dev <llvm-dev at lists.llvm.org> wrote:> A few hints:Another one for debug builds on Linux is using split debug info: -DLLVM_USE_SPLIT_DWARF=ON. This speeds up links dramatically (and reduces memory consumption) as long as you've got a new enough gdb (I think lldb is still not quite up to it). It has no effect on macOS though, because a similar configuration is just how things work there. Tim.