scripts: Scale number of make jobs by hardware thread count

If the hardware thread/core count cannot be determined successfully,
avoid setting the '-j' option for make.
This commit is contained in:
Albert Ou
2019-08-31 14:51:14 -07:00
parent cff1f6b11e
commit 4963792e98

View File

@@ -110,7 +110,18 @@ else
mkdir -p "$RISCV" mkdir -p "$RISCV"
git -C "${CHIPYARD_DIR}" submodule update --init --recursive "toolchains/${TOOLCHAIN}" #--jobs 8 git -C "${CHIPYARD_DIR}" submodule update --init --recursive "toolchains/${TOOLCHAIN}" #--jobs 8
cd "$CHIPYARD_DIR/toolchains/$TOOLCHAIN" cd "$CHIPYARD_DIR/toolchains/$TOOLCHAIN"
export MAKEFLAGS="-j16"
# Scale number of parallel make jobs by hardware thread count
ncpu="$(getconf _NPROCESSORS_ONLN || # GNU
getconf NPROCESSORS_ONLN || # *BSD, Solaris
nproc --all || # Linux
sysctl -n hw.ncpu || # *BSD, OS X
:)" 2>/dev/null
case ${ncpu} in
''|*[^0-9]*) ;; # Ignore non-integer values
*) export MAKEFLAGS="-j ${ncpu}" ;;
esac
#build the actual toolchain #build the actual toolchain
#./build.sh #./build.sh
source build.common source build.common
@@ -128,7 +139,7 @@ else
cd "$RDIR" cd "$RDIR"
# build linux toolchain # build linux toolchain
cd "$CHIPYARD_DIR/toolchains/$TOOLCHAIN/riscv-gnu-toolchain/build" cd "$CHIPYARD_DIR/toolchains/$TOOLCHAIN/riscv-gnu-toolchain/build"
make -j16 linux make linux
echo -e "\\nRISC-V Linux GNU Toolchain installation completed!" echo -e "\\nRISC-V Linux GNU Toolchain installation completed!"
fi fi