[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] Improve genmoddep.awk
From: |
Pavel Roskin |
Subject: |
[PATCH 1/3] Improve genmoddep.awk |
Date: |
Tue, 30 Jun 2009 20:35:03 -0400 |
User-agent: |
StGIT/0.14.3 |
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 += address@hidden #{mod_obj} #{mod_src} #{pre_obj} #{objs_str}
#{undsym}
+ "CLEANFILES += address@hidden #{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)
address@hidden: #{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"];
}
}
- [PATCH 1/3] Improve genmoddep.awk,
Pavel Roskin <=