From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MLnn7-0006Jc-7N for mharc-grub-devel@gnu.org; Tue, 30 Jun 2009 20:35:13 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLnn5-0006Gg-Hw for grub-devel@gnu.org; Tue, 30 Jun 2009 20:35:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLnn0-000667-IR for grub-devel@gnu.org; Tue, 30 Jun 2009 20:35:10 -0400 Received: from [199.232.76.173] (port=52174 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLnn0-00065q-Ee for grub-devel@gnu.org; Tue, 30 Jun 2009 20:35:06 -0400 Received: from c60.cesmail.net ([216.154.195.49]:17877) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MLnmz-0000Ra-VH for grub-devel@gnu.org; Tue, 30 Jun 2009 20:35:06 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 30 Jun 2009 20:35:04 -0400 Received: from mj.roinet.com (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id D4B3434C6D for ; Tue, 30 Jun 2009 20:42:25 -0400 (EDT) From: Pavel Roskin To: grub-devel@gnu.org Date: Tue, 30 Jun 2009 20:35:03 -0400 Message-ID: <20090701003502.25373.82948.stgit@mj.roinet.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH 1/3] Improve genmoddep.awk 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: Wed, 01 Jul 2009 00:35:12 -0000 Avoid pipeline in its invocation. It's hard to get the result of a pipeline reliably. Eliminate the need in "und-*" files by caching and postprocessing undefined symbols. ChangeLog: * Makefile.in: Invoke genmoddep.awk without any pipelines. Eliminate UNDSYMFILES. * genmk.rb: Write undefined symbols to the same files as defined symbols. * genmoddep.awk: Process only files from the command line, recognize defined symbols by the number of records. Save undefined symbols in a table, process them later. Output to the file specified by the MODDEP environment variable. Report all undefined symbols. --- Makefile.in | 6 ++---- genmk.rb | 17 ++++++----------- genmoddep.awk | 39 ++++++++++++++++++++++++--------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Makefile.in b/Makefile.in index f82566a..e6be9c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -148,10 +148,8 @@ include $(srcdir)/conf/$(target_cpu)-$(platform).mk CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst -moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk - cat $(DEFSYMFILES) /dev/null \ - | $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \ - || (rm -f $@; exit 1) +moddep.lst: $(DEFSYMFILES) genmoddep.awk + MODDEP=$@ $(AWK) -f $(srcdir)/genmoddep.awk $(DEFSYMFILES) command.lst: $(COMMANDFILES) cat $^ /dev/null | sort > $@ diff --git a/genmk.rb b/genmk.rb index e3866c1..2883362 100644 --- a/genmk.rb +++ b/genmk.rb @@ -110,17 +110,15 @@ class PModule mod_src = 'mod-' + @name.suffix('c') mod_obj = mod_src.suffix('o') defsym = 'def-' + @name.suffix('lst') - undsym = 'und-' + @name.suffix('lst') mod_name = File.basename(@name, '.mod') symbolic_name = mod_name.sub(/\.[^\.]*$/, '') - "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym} + "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} ifneq ($(#{prefix}_EXPORTS),no) CLEANFILES += #{defsym} DEFSYMFILES += #{defsym} endif MOSTLYCLEANFILES += #{deps_str} -UNDSYMFILES += #{undsym} ifneq ($(TARGET_APPLE_CC),1) #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) @@ -148,19 +146,16 @@ endif sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1) ifneq ($(#{prefix}_EXPORTS),no) -ifneq ($(TARGET_APPLE_CC),1) #{defsym}: #{pre_obj} - $(NM) -g --defined-only -P -p $< | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > $@ + echo '#{mod_name}' > $@ + $(NM) -u -P -p $< | cut -f1 -d' ' >> $@ +ifneq ($(TARGET_APPLE_CC),1) + $(NM) -g --defined-only -P -p $< | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' >> $@ else -#{defsym}: #{pre_obj} - $(NM) -g -P -p $< | grep -E '^[a-zA-Z0-9_]* [TDS]' | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > $@ + $(NM) -g -P -p $< | grep -E '^[a-zA-Z0-9_]* [TDS]' | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' >> $@ endif 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') diff --git a/genmoddep.awk b/genmoddep.awk index f7f085e..db8e07e 100644 --- a/genmoddep.awk +++ b/genmoddep.awk @@ -11,11 +11,14 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -# Read defined symbols from stdin. -BEGIN { - while (getline <"/dev/stdin") { - symtab[$1] = $2 - } +# This program processes lists of defined and undefined symbols given on +# the command line. The output filename is determined by the MODDEP +# environment variable. + +# Each defined symbol is followed by the module name. +NF == 2 { + symtab[$1] = $2 + next } # The first line contains a module name. @@ -25,19 +28,25 @@ FNR == 1 { }; # The rest is undefined symbols. -{ - if ($1 in symtab) { - modtab[module] = modtab[module] " " symtab[$1]; - } - else { - printf "%s in %s is not defined\n", $1, module >"/dev/stderr"; - error++; - exit; - } +NF == 1 { + undtab[$1] = undtab[$1] " " module } # Output the result. END { + for (sym in undtab) { + if (sym in symtab) { + split(undtab[sym], mods, " "); + for (i in mods) { + modtab[mods[i]] = modtab[mods[i]] " " symtab[sym]; + } + } + else { + printf "Symbol \"%s\" is not defined in modules:%s\n", sym, undtab[sym] >"/dev/stderr"; + error = 1; + } + } + if (error == 1) exit 1; @@ -57,6 +66,6 @@ END { for (depmod in uniqmods) { modlist = modlist " " depmod; } - printf "%s:%s\n", mod, modlist; + printf "%s:%s\n", mod, modlist >ENVIRON["MODDEP"]; } }