Mercurial > hg > toybox
changeset 1446:f46ccbcf3f13 draft
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.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 24 Aug 2014 22:42:47 -0500 |
parents | 8b7ddefcf28c |
children | 487716951287 |
files | scripts/make.sh |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/make.sh Sat Aug 23 23:08:59 2014 -0500 +++ b/scripts/make.sh Sun Aug 24 22:42:47 2014 -0500 @@ -7,11 +7,7 @@ [ -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 @@ # 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 @@ 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