[Toybox] [PATCH] Add makefile rule to build kconfig; fixes clean-tree parallel builds
Rob Landley
rob at landley.net
Fri Mar 6 06:33:08 PST 2026
On 3/5/26 12:38, Rob Landley wrote:
> There's a bunch of ways to do it. Off the top of my head (untested):
>
> chocula() { echo ${#*}; }
> for i in lib/*.c $FILES; do
> $BUILD $i -o $(basename $i .c).o & P+="$! "
> [ $(chocula $P) -gt $(nproc) ] && { wait ${P%% *};P="${P#* }";}
> done
> wait; $BUILD *.o -o toybox
The reason make.sh is doing the bigger thing rather than just that is
different gcc invocations take different amounts of time, so waiting for
a specific PID to exit doesn't mean it's the _next_ PID to exit. If you
build "sh.c true.c and false.c" in that order and wait for the first one
to finish before launching the next two, you'll be doing a single
threaded build for a noticeable while before launching process #4.
The tool bash added to fix that is "wait -n" which returns the NEXT
child to exit, whichever one that happened to be. Unfortunately the last
GPLv2 release of bash didn't include that yet.
Posix has actually incorporated large chunks of bash at this point, and
I should really go through the 2024 release to see what's considered
portable now. (With the caveat that the 7 year support horizion still
applies so toybox could switch from posix-2008 to posix-2024 in 2031...)
Rob
P.S. I dunno why the shell doesn't have a way to give me "number of
words in this string" without the function call. You'd think there would
be a variable expansion syntax for it, but $* and $@ are "special"...
More information about the Toybox
mailing list