What is a good CPU / PC setup to speed up intensive C ++ / templates compilation?

I currently have a car with Opteron 275 (2.2 GHz), which is a dual-core processor and 4 GB of RAM, as well as a very fast hard drive. I find that when compiling even a few simple projects using C ++ templates (think boost, etc.), the compilation time can take quite a lot of time (minutes for small things, much more for large projects). Unfortunately, only one of the kernels is 100% bound, so I know that this is not I / O, and it would seem that there is no way to use another kernel to compile C ++?

+3
source share
3 answers

Compile-time problems with templates are often related to communication problems, rather than compilation problems.

Using templates inside your .cpp files, but making sure the headers do not actually contain a template is a good way to fix them. This can be done either by declaring the class, or by wrapping your implementation class in an abstract base class that simply declares public members (mostly the Pimpl idiom).

+4
source

Do you use precompiled headers? They usually provide the biggest compilation speed acceleration I get with my C ++ projects.

, . , Visual ++ /MP (. ), /MP , .

+7

To use multi-threaded compilation on Makefile-based systems, look at the -j switch, it is usually recommended to call

make -j<number of cores + 1>
+1
source

Source: https://habr.com/ru/post/1737458/


All Articles