If you use gcc and would like to shorten compilation time, you may achive it with make -j. This way you will use all cores of CPU(s) you are compile your software on.

And if you ever wander how much you can gain using make -j here some of my notes that may be usefull for you.

hardware

Servers used in tests (manufacturer IBM):

  CPU: 2x Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz ( disabled HT )
  RAM: 64 GB
  HDD: 1TB SATA 7.2k  drive
  OS:  CentOS 7.7.1908 x86_64, with gcc version 4.8.5.

test

Test mesured real time ( with command time ) of make -j${N} command. For N={1,2,4,6,8,10,12,14,16}. Also time of just command make and make -j was measured.

results ( gcc 5.5.0 )

Compilation time when only make and make -j commands were used:

|         | make    | make -j |
| test1   | 8758.35 | 1398.80 |
| test2   | 8808.69 | 1406.01 |
| test3   | 8752.77 | 1380.59 |
| ------- | ------- | ------- |
| avg [s] | 8773.27 | 1395.13 |

Compilation times when make -jN was used:

| N       | 1       | 2       | 4       | 6       | 8       | 10      | 12      | 14      | 16      |
| ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
| t1 [s]  | 9262.00 | 4550.52 | 2361.39 | 2071.81 | 1554.89 | 1701.20 | 1508.04 | 1211.95 | 1228.44 |
| t2 [s]  | 9068.11 | 4526.52 | 2369.52 | 2009.84 | 1597.10 | 1646.83 | 1502.74 | 1221.29 | 1195.89 |
| t3 [s]  | 8775.13 | 4719.51 | 1215.84 | 2080.98 | 1556.12 | 1645.79 | 1484.81 | 1191.70 | 1184.25 |
| ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
| avg [s] | 9035.08 | 4598.85 | 2356.31 | 2054.21 | 1569.37 | 1664.61 | 1498.53 | 1208.31 | 1202.86 |
| eff [%] |  100.00 |   98.23 |   95.86 |   73.31 |   71.96 |   54.28 |   50.24 |   53.41 |   46.95 |

results ( gcc 9.3.0 )

Compilation time when only make and make -j commands were used:

|           | make     | make -j |
| test1 [s] | 11184.95 | 1590.03 |
| test2 [s] | 11138.40 | 1588.29 |
| test3 [s] | 11118.13 | 1580.91 |
| test4 [s] | 11418.51 | 1581.73 |
| --------- | -------- | ------- |
| avg [s]   | 11215.00 | 1585.24 |

Compilation times when make -jN was used:

| N       | 1        | 2       | 4       | 6       | 8       | 10      | 12      | 14      | 16      |
| ------- | -------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
| t1 [s]  | 11130.18 | 5780.03 | 3072.61 | 2352.69 | 2057.15 | 1814.31 | 1715.14 | 1622.43 | 1548.45 |
| t2 [s]  | 11121.15 | 5796.44 | 3064.49 | 2369.70 | 2061.23 | 1822.93 | 1708.83 | 1609.93 | 1553.69 |
| t3 [s]  | 11424.66 | 5798.66 | 3078.99 | 2365.91 | 2073.97 | 1828.92 | 1719.09 | 1626.45 | 1547.62 |
| t4 [s]  | 11131.87 | 5754.12 | 3066.07 | 2363.79 | 2060.95 | 1846.97 | 1728.84 | 1631.61 | 1553.31 |
| ------- | -------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
| avg [s] | 11201.97 | 5782.31 | 3070.54 | 2363.02 | 2063.33 | 1828.28 | 1717.98 | 1622.61 | 1550.77 |
| eff [%] |   100.00 |   96.86 |   91.21 |   79.01 |   68.86 |   61.27 |   54.34 |   49.31 |   45.15 |

compilation time

other

You can read more about -j option at man pages with man make.

These are commands used to download and compile gcc 5.5.0 from source ( similar command were used to prepare gcc-9.3.0 ).

cd /tmp/
wget http://mirror.koddos.net/gcc/releases/gcc-5.5.0/gcc-5.5.0.tar.xz
tar xJf gcc-5.5.0.tar.xz
cd gcc-5.5.0
./contrib/download_prerequisites
./configure --disable-multilib --prefix=/opt/gcc-5.5.0
time make -j${N}
make install