On Wednesday 17 March 2010 10:16:34 David N. Lombard wrote:
> On Mon, Mar 15, 2010 at 03:02:26PM -0700, Rob Landley wrote:
> > On Monday 15 March 2010 04:43:56 Ralf Friedl wrote:
> > > If you place everything in one big include file, with preprocessor
> > > conditions on the definition of THIS, you will trigger a recompile of
> > > all files whenever you change a single file.
> >
> > ... In fact, does
> > anybody except applet developers ever do anything _except_ build all from
> > a clean start?)
>
> That quite true. Unless I'm specifically chasing something in busybox,
> it's always (re)built completely. It ensures a linear, well-defined path,
> instead of some random walk.
For toybox, my Makefile's non-phony targets boil down to:
all: toybox
toybox toybox_unstripped: .config *.[ch] lib/*.[ch] toys/*.[ch] scripts/*.sh
scripts/make.sh
And then in make.sh i've got the stuff to regenerate the generated/* stuff
(which you'll notice the above dependencies do _not_ look at), and then the
build itself is (with some enviornment variables expanded):
# Figure out which toys/*.c files are enabled in .config
TOYFILES=$(cat .config | sed -nr \
-e 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' | \
sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's...@\(.*\)@toys/\1.c@' )
# Compile toybox
$CC $CFLAGS -Wall -Wundef -Wno-char-subscripts -funsigned-char -I . \
-o toybox_unstripped -Os -ffunction-sections -fdata-sections \
-Wl,--gc-sections main.c lib/*.c $TOYFILES \
-Wl,--as-needed,-lutil,--no-as-needed || exit 1
$STRIP toybox_unstripped -o toybox || exit 1
I wasn't trying to push that part into busybox, but essentially I do a "make
all" whenever anything changes, and let the compiler discard unneeded code.
My build logic is fairly simple as a result, and doesn't actually take that
long. (When you "make all" as often as I do, you find ways to keep the compile
time down. :) Also, if I'm testing just one app I can .config everything else
off, but mostly I don't bother...
The main downside is that doesn't take advantage of SMP, but that's really a
compiler issue. (You can't have the compiler doing gc-sections _and_ take
proper advantage of SMP until your compiler becomes multi-threaded. I
blathered about this topic for way too long at an an OLF bof a few years back,
http://free-electrons.com/pub/video/2008/ols/ols2008-rob-landley-linux-
compiler.ogg )
As I said, it's still pretty fast anyway. Admittedly toybox only has about 40
commands right now and busybox has around 7 times that many. But toybox takes
just under 9 seconds to do a defconfig build on my laptop. With a cold cache,
current busybox takes about that long to figure out it has nothing to do when
you type "make" in a directory that's already built everything. Complicating
things does not streamline them.
Rob
--
Latency is more important than throughput. It's that simple. - Linus Torvalds
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox