grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Avoid recompilation of unrelated files


From: Bean
Subject: [PATCH] Avoid recompilation of unrelated files
Date: Wed, 27 Jun 2007 02:52:12 +0800
User-agent: Mutt/1.5.13 (2006-08-11)

A problem of the grub2 make system is that even the smallest change of source
code can trigger a huge recompilation. Try this:

touch commands/cmp.c
make

The ideal situation is that only files related to cmp module is recompiled. 
But unfortunately, this is not the case. The problem lies in file dependence.

cmp.mod: pre-cmp.o mod-cmp.o

pre-cmp.o: cmp_mod-commands_cmp.o

cmp_mod-commands_cmp.o: cmp.c

mod-cmp.o: mod-cmp.c

mod-cmp.c:  moddep.lst genmodsrc.sh

def-cmp.lst: pre-cmp.o

und-cmp.lst: pre-cmp.o

moddep.lst: def-cmp.lst und-cmp.lst

cmp.c => cmp_mod-commands_cmp.o => pre-cmp.o => def-cmp.lst and und-cmp.lst
=> moddep.lst

When cmp.c changes, moddep.lst changes. But every mod-*.c depends on 
moddep.lst, they all need to be recreated. This will lead to a huge
recompilation process.

def-cmp.lst and und-cmp.lst contains the exported symbol and unresolved symbol
of the module. Their content rarely change. So we can update them only when 
it's necessary, not every time we recompile the module.

The solution:

Merge these three rules:

pre-cmp.o: cmp_mod-commands_cmp.o

def-cmp.lst: pre-cmp.o

und-cmp.lst: pre-cmp.o

The output of def-cmp.lst is saved as tmp_pre-cmp.lst. When tmp_pre-cmp.lst
and the old pre-cmp.lst is different, move tmp_pre-cmp.lst to pre-cmp.lst, 
otherwise, just delete tmp_pre-cmp.lst. und-cmp.lst can be handled in exactly
the same way.

-- 
Bean

Attachment: grub2-genmk.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]