From 5d16faa426b641aefe2d019cbbf76a3d49c4549f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 24 Aug 2014 22:42:47 -0500 Subject: Fix parallel make not always catching errors before link time. jobs -p removes finished jobs from the list after reporting them once, so we need to record the output and remove duplicates ourselves. --- scripts/make.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/make.sh b/scripts/make.sh index 502c8cd1..38b8f071 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -7,11 +7,7 @@ source ./configure [ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=".config" -if [ -z "$CPUS" ] -then - CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w) - CPUS=$(($CPUS+1)) -fi +[ -z "$CPUS" ] && CPUS=$(($(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+1)) # Respond to V= by echoing command lines as well as running them do_loudly() @@ -188,6 +184,7 @@ LINK="-o toybox_unstripped -Wl,--as-needed $(cat generated/optlibs.dat)" # This is a parallel version of: do_loudly $BUILD $FILES $LINK || exit 1 rm -f generated/*.o +PENDING= for i in $FILES do # build each generated/*.o file in parallel @@ -200,14 +197,17 @@ do while true do - [ $(jobs -rp | wc -w) -lt "$CPUS" ] && break; - wait $(jobs -p | head -n 1) || exit 1 + PENDING="$(echo $PENDING $(jobs -rp) | tr ' ' '\n' | sort -u)" + [ $(echo $PENDING | wc -l) -lt "$CPUS" ] && break; + + wait $(echo $PENDING | head -n 1) || exit 1 + PENDING="$(echo "$PENDING" | tail -n +2)" done done # wait for all background jobs, detecting errors -for i in $(jobs -p) +for i in $PENDING do wait $i || exit 1 done -- cgit v1.2.3