Since I am compiling my C++ code on a very server box (32 or 64 cores in total), is there a way of tweaking compiler options to speed up the compilation times? E.g. to tell compiler to compile independent .cpp files using multiple threads.
Asked
Active
Viewed 1,016 times
4 Answers
4
This depends on what toolchain you're using.
If you're using GNU Make, then add -j 32
to your make invocation to tell Make to start 32 jobs (for example) in parallel. Just make sure that you're not exhausting RAM and thrashing your swap file as a result.

Josh Kelley
- 56,064
- 19
- 146
- 246
4
Sun Studio includes parallel build support in the included dmake
version of make.
See the dmake manual for details.

alanc
- 4,102
- 21
- 24
-
1dmake -j 64 has reduced a compilation time from over two minutes to under 4 seconds... fantastic. – Steve Jul 09 '10 at 03:21
3
Use something like Boost JAM which does this sort of multithreading for you - and from my experience much more efficiently than multi-threaded make.

Michael Dorgan
- 12,453
- 3
- 31
- 61
0
Sun's C++ compiler also has an -xjobs
option that makes the compiler fork multiple threads internally. For this to be efficient you would probably have to pass all .cc files to a single invocation of CC.

Asgeir S. Nilsen
- 1,137
- 9
- 13