Patch: cut 'make dep' time in half

Michael Elizabeth Chastain (mec@shout.net)
Thu, 5 Dec 1996 06:46:55 -0600


Hello kernel hackers,

I have a 'make dep' that runs in half the time of the stock 2.1.14 version.
My patch is attached. Don't worry, it's less than 100 lines.

Instead of visiting directories in 'Make', I wrote a new script
'mkdep-tree' that visits all the directories in a set of trees.

I have a IBM SLC-486/2 66 MHz with a no-name IDE controller. My total
time for 'make dep' dropped from 243 seconds to 112 seconds. About 17
seconds of this are fake, however, because of conmakehash (see below).

Actually executing 'mkdep' takes less than half of the execution
time for 'make dep'!

My patch has three drawbacks:

1) No more fastdep hook in sub-makefiles
2) Warnings in drivers/sound/lowlevel
3) moduleversions.h

The first major drawback is that the sub-makefiles no longer have
'fastdep' rules. This is the core of the trade-off. I have to lose
these rules in order to get the 50% time reduction.

The only fastdep rule I found in actual Makefiles was
drivers/char/Makefile, for uni_hash.tbl. I simply hung that on a .o
file instead.

The second drawback is that my new 'mkdep-tree' visits the directory
drivers/sound/lowlevel, which is not yet wired up for the old 'mkdep'.
The files in there give errors when mkdep-tree calls mkdep:

aci.c needs config but has not included config file
awe_wave.c needs config but has not included config file

You can ignore these warnings. The fix, of course, is to add
#include <linux/config.h> to these files.

The third drawback is that I don't understand what's going on with
'moduleversions.h' in the current Rules.make, so I just ignored it.
Advise appreciated!

Please, if you want 'make dep' to be faster and you think this is
a viable approach, try out this patch and send me e-mail about it.
I'm not going to submit it to Linus Torvalds until I have several
success reports in hand. And, of course, if I get failure reports,
that can save a lot of innocent victims even more time. :)

Michael Chastain
mec@shout.net

diff -u -r -N --exclude-from=exclude.files linux-2.1.14/Makefile linux/Makefile
--- linux-2.1.14/Makefile Sat Nov 23 13:28:45 1996
+++ linux/Makefile Thu Dec 5 05:53:53 1996
@@ -348,7 +348,7 @@
dep-files: scripts/mkdep archdep include/linux/version.h
scripts/mkdep init/*.c > .tmpdepend
scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend
- set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep; done
+ /bin/sh scripts/mkdep-tree $(SUBDIRS)
mv .tmpdepend .depend

MODVERFILE :=
diff -u -r -N --exclude-from=exclude.files linux-2.1.14/Rules.make linux/Rules.make
$(M_OBJS): $(TOPDIR)/include/linux/modversions.h
diff -u -r -N --exclude-from=exclude.files linux-2.1.14/drivers/char/Makefile linux/drivers/char/Makefile
--- linux-2.1.14/drivers/char/Makefile Fri Nov 22 10:03:43 1996
+++ linux/drivers/char/Makefile Thu Dec 5 06:10:44 1996
@@ -206,9 +206,7 @@

include $(TOPDIR)/Rules.make

-fastdep: uni_hash.tbl
-
-consolemap.o:
+consolemap.o: uni_hash.tbl

conmakehash: conmakehash.c
$(HOSTCC) -o conmakehash conmakehash.c
diff -u -r -N --exclude-from=exclude.files linux-2.1.14/scripts/mkdep-tree linux/scripts/mkdep-tree
--- linux-2.1.14/scripts/mkdep-tree Thu Jan 1 00:00:00 1970
+++ linux/scripts/mkdep-tree Thu Dec 5 05:53:48 1996
@@ -0,0 +1,21 @@
+#! /bin/sh
+# Copyright 1996 Michael Elizabeth Chastain <mec@shout.net>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2, or (at your option) any
+# later version.
+#
+# This script takes a list of directory names as input. First it finds
+# all of the subdirectories in this list of directory trees which have
+# any files that match the pattern *.[chS]. Then it visits those
+# directories and runs mkdep on each one.
+
+set -e
+dir_top=`pwd`
+dir_list=`find $* -name '*.[chS]' -print | sed -e 's/^\(.*\)\/[^\/].*$/\1/p' | sort -u`
+for dir in $dir_list ; do
+ cd $dir
+ $dir_top/scripts/mkdep *.[chS] > .depend
+ cd $dir_top
+done