All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Improve genmoddep.awk
@ 2009-07-01  0:35 Pavel Roskin
  2009-07-01  0:35 ` [PATCH 2/3] Don't put modules without dependencies into moddep.lst Pavel Roskin
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Pavel Roskin @ 2009-07-01  0:35 UTC (permalink / raw)
  To: grub-devel

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"];
   }
 }



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-07-04 20:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-01  0:35 [PATCH 1/3] Improve genmoddep.awk Pavel Roskin
2009-07-01  0:35 ` [PATCH 2/3] Don't put modules without dependencies into moddep.lst Pavel Roskin
2009-07-01 13:10   ` Robert Millan
2009-07-01 13:20     ` Pavel Roskin
2009-07-04 20:09       ` Robert Millan
2009-07-01  0:35 ` [PATCH 3/3] Use ELF symbols without "32" or "64" Pavel Roskin
2009-07-01  3:44 ` [PATCH 1/3] Improve genmoddep.awk Bean
2009-07-01  4:51   ` Pavel Roskin
2009-07-01  5:22     ` Bean
2009-07-01 12:35       ` Pavel Roskin
2009-07-01 13:13       ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.