# HG changeset patch # User Michael Hope # Date 1317253242 -46800 # Node ID f2495884ca3e89f6c360a63a6e6604da652b8336 # Parent 2c01a02334ea52148a82efac24de371e6d5dc82b config: add a 'auto' value for the number of parallel jobs When CT_PARALLEL_JOBS is -1, set the number of parallel jobs to the number of online CPUs + 1. Update documentation to match. I find this useful when building in the cloud. You can use the same .config file and have the build adapt to the number of processors available. Limited testing shows that NCPUS+1 is faster than NCPUS+0 or NCPUS+2. Signed-off-by: Michael Hope diff -r 2c01a02334ea -r f2495884ca3e config/global/build-behave.in --- a/config/global/build-behave.in Thu Sep 29 12:27:54 2011 +1300 +++ b/config/global/build-behave.in Thu Sep 29 12:40:42 2011 +1300 @@ -16,6 +16,8 @@ Enter 1 (or 0) to have only one job at a time. + Enter -1 to set automatically based on how many processors the host has. + config LOAD int prompt "Maximum allowed load" if ! BACKEND diff -r 2c01a02334ea -r f2495884ca3e scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Thu Sep 29 12:27:54 2011 +1300 +++ b/scripts/crosstool-NG.sh.in Thu Sep 29 12:40:42 2011 +1300 @@ -488,7 +488,11 @@ # And help make go faster JOBSFLAGS= - [ ${CT_PARALLEL_JOBS} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" + # Use the number of processors+1 when automatically setting the number of + # parallel jobs. Fall back to 1 if the host doesn't use GLIBC. + AUTO_JOBS=$((`getconf _NPROCESSORS_ONLN 2> /dev/null || echo 0` + 1)) + [ ${CT_PARALLEL_JOBS} -eq -1 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}" + [ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" [ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}" # We need to save the real .config with kconfig's value,