Like: make -jx // where x is automatically detected

After reading the answer to this question: Make "make" by default is "make -j 8"

I am wondering if there is a way to make the -j option automatically use the correct number of compiled streams?

So I say make . And does the make command itself use 6 or 4 or 8 threads depending on the hardware?

+4
source share
1 answer

make doesn't look for the number of cores on its own if you just use make -j - instead, it parallels with max. However, you should be able to determine the number of cores per

 grep -c "^processor" /proc/cpuinfo 

or (as commented by Azor-Ahai, if available on your system)

 nproc 

Consequently:

 make -j $(nproc) 

For more information on how to get the number of processors / kernels in Linux from the command line ?, see "How . In addition, see GNU make: should the number of jobs equal the number of processor cores in the system?

+12
source

All Articles