From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1I3G9d-00038Q-5X for mharc-grub-devel@gnu.org; Tue, 26 Jun 2007 14:52:45 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I3G9b-000389-Sj for grub-devel@gnu.org; Tue, 26 Jun 2007 14:52:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I3G9Z-00037s-Sc for grub-devel@gnu.org; Tue, 26 Jun 2007 14:52:42 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I3G9Z-00037n-LJ for grub-devel@gnu.org; Tue, 26 Jun 2007 14:52:41 -0400 Received: from m15-112.126.com ([220.181.15.112]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1I3G9Y-0002tQ-4W for grub-devel@gnu.org; Tue, 26 Jun 2007 14:52:41 -0400 Received: from localhost (unknown [121.201.45.43]) by smtp2 (Coremail) with SMTP id wKjJDLAbYAFyYIFGyb4eBQ==.20930S2; Wed, 27 Jun 2007 02:52:35 +0800 (CST) Date: Wed, 27 Jun 2007 02:52:12 +0800 From: Bean To: The development of GRUB 2 Message-ID: <20070626185212.GA3822@ws3.vdp.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Coremail-Antispam: 1U3Yxn0WfASr-VFAUDIcSsGvfJTg7C26xCjj4IEI4klw4CSww Aac4AC62xK8xCEY4vEwIxC4wC2zVAF1VAY17CE14v26r1j6r15Mx02cVAKzwASzI0EjI02 j7AqF2xKxwAv7VC0I7IYx2IY67AKxVWUJVWUGwCF72vE52k0Y41lYx0Ex4A2jsIE14v26r 1j6r4UM7C26IkvcIIF6IxKo4kEV4ylc2IjII80xcxEwVAKI48JM7AC8VAFwI0_Jr0_Gr1l b4IE77IF4wAFIxvE14AKwVWUJVWUGwAqx4xG64xvF2IEw4CE5I8CrVC2j2Wlb7Iv0xC_KF 7anT9S1TB71UUUUUUa7-sFnT9fnUUI43ZEXa7IUeZvttUUUUUFnT9fnV15pF1DZr1UWrWx tFWUAF13XF4kXoXrpr48trg_ur1xJ345C34UAws5A3yft3WrZr4rWw4DJr4DAr9rXr1jy3 s0gr4fXrsYvrnagFW7ZFnIyry5Ar47Z3W8u3Wj9 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Subject: [PATCH] Avoid recompilation of unrelated files X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2007 18:52:44 -0000 --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="grub2-genmk.diff" * genmk.rb: Avoid recompilation of unrelated files. Index: genmk.rb =================================================================== RCS file: /sources/grub/grub2/genmk.rb,v retrieving revision 1.27 diff -u -r1.27 genmk.rb --- genmk.rb 22 Sep 2006 00:27:38 -0000 1.27 +++ genmk.rb 26 Jun 2007 18:06:28 -0000 @@ -120,6 +120,13 @@ #{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str} -rm -f $@ $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str} +ifneq ($(#{prefix}_EXPORTS),no) + $(NM) -g --defined-only -P -p $< | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > tmp_#{defsym} + if cmp -s tmp_#{defsym} #{defsym} ; then rm tmp_#{defsym} ; else mv tmp_#{defsym} #{defsym} ; fi +endif + echo '#{mod_name}' > tmp_#{undsym} + $(NM) -u -P -p $< | cut -f1 -d' ' >> tmp_#{undsym} + if cmp -s tmp_#{undsym} #{undsym} ; then rm tmp_#{undsym} ; else mv tmp_#{undsym} #{undsym} ; fi #{mod_obj}: #{mod_src} $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $< @@ -127,15 +134,6 @@ #{mod_src}: moddep.lst genmodsrc.sh sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1) -ifneq ($(#{prefix}_EXPORTS),no) -#{defsym}: #{pre_obj} - $(NM) -g --defined-only -P -p $< | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > $@ -endif - -#{undsym}: #{pre_obj} - echo '#{mod_name}' > $@ - $(NM) -u -P -p $< | cut -f1 -d' ' >> $@ - " + objs.collect_with_index do |obj, i| src = sources[i] fake_obj = File.basename(src).suffix('o') --4Ckj6UjgE2iN1+kY--