Search code examples
gcccompilationclang

Can one compiler installation be used to compile multiple projects in parallel?


The more precise question is: can compiler's executable file be called multiple times in parallel, with potentially different options, to compile multiple projects. If yes, will compilation of multiple projects in parallel show any decrease in performance in comparison to compiling next project after previous has finished? The motivation for this question is that in theoretical project that would contain code for libraries and exe file that depends on them, libraries could be compiled in parallel and after that exe file would be compiled. The question is mainly about gcc and clang compilers, as these in my opinion are at the moment most popular.


Solution

  • Multiple projects can be compiled in parallel using GCC, assuming your dependencies resolve correctly. On a side note, you can even run the compilation process using a multi-core strategy using gcc -pipe. The compiler's performance will, theoretically, be improved due to the common libraries being shared in memory. This performance gain is not without constraint, as the hardware you run the compilations and the size of the compilations will determine how fast they will run. To take this further, you could theoretically start, say, 1000 compilation processes at the same time, but it most likely would not be as performant as just keeping 5 or 10 running using a process scheduling system.