This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Recursive make harmful (was: Re: what should bootstrap *really* do?)
- To: "Eric W. Biederman" <ebiederm at xmission dot com>
- Subject: Recursive make harmful (was: Re: what should bootstrap *really* do?)
- From: Scott A Crosby <crosby at qwes dot math dot cmu dot edu>
- Date: Mon, 20 Nov 2000 19:39:33 -0500 (EST)
- cc: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>, dj at redhat dot com, kenner at vlsi1 dot ultra dot nyu dot edu, gcc at gcc dot gnu dot org
A web-search doesn't show this paper as having been on the gcc list yet,
I'll send it along. It discusses why recursive make is harmful and other
misuses of make.
-- http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html
I would suggest reading it if you're working on the build system.
Fundamentally, most of the time when recursive make is used, it's actually
lying about the dependency DAG. As workarounds, people have to insert
wierd and special rules, or have 'marker' files. Sometimes, it can be
easier to just not lie. You can have the makefile in one directory include
makefiles in other directories if necessary.
It's been used in other places, for example, there is the thread on
linux-kernel, where it was reported to make building much faster and make
one makefile 800 lines shorter:
http://www.uwsg.iu.edu/hypermail/linux/kernel/0001.3/0012.html
Your explanation is perfectly reasonable. You may have makefiles in one
directory including makefiles in another directory, but there are no
recursive make's. If someone want's to do a check by doing a partial
build, do something like my sample.
Below, I give a sample. For the most part, this sample still lets do a
'make' in a subdirectory. and it will only build that portion. I do
violate my principal of not doing recursive make only in one place: For
each module I check, I do one recursive 'make'.
I've run a benchmark of building 2.95.2 on my machine, to report where CPU
usage is going throughout the build process. I will be sending it to the
mailing list shortly.
Scott
On 16 Nov 2000, Eric W. Biederman wrote:
> Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:
>
> So why not do:
>
> stage1/foo.o : foo.c
> cc -c foo.c -o foo.o && mv foo.o stage1/foo.o
>
> stage2/foo.o : foo.c stage1/gcc
> stage1/gcc -c foo.c -o foo.o && mv foo.o stage2/foo.o
>
> stage3/foo.o : foo.c stage2/gcc
> stage2/gcc -c foo.c -o foo.o && mv foo.o stage3/foo.o
>
> bootstrap: stage3/gcc
>
> Then you can restart when ever you want.
>
> Nice simple, builds in the normal directory, stores the files in
> the stage directories.
>
My sample... Incomplete, but enough to give you an idea:
##
##
## In $SRC/Makefile
##
##
include $SRC/gcc/Makefile
##
##
## In $SRC/gcc/Makefile
##
##
$build/stage1: stage1/xgcc
$build/stage1/xgcc: ${STAGE1_OBJS}
${CC} _______
check-gcc-stage1: $(build)/stage1/xgcc $(deja)
$(MAKE) -f Makefile.check check CHECK_GCC=stage1/xgcc
check-gcc-stage3: $(build)/stage3/xgcc $(deja)
$(MAKE) -f Makefile.check check CHECK_GCC=stage3/xgcc
# Dependency for check.
check: check-gcc-stage3