Skip to contentSkip to conversation

Improve genmoddep.awk

PATCH In review Pavel Roskin 3 participants 11 messages Jul 1, 2009 – Jul 4, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Improve genmoddep.awk

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(-)
Makefile.in +2 -4
index f82566a..e6be9c4 100644
@@ -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 > $@
genmk.rb +6 -11
index e3866c1..2883362 100644
@@ -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')
genmoddep.awk +24 -15
index f7f085e..db8e07e 100644
@@ -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"];
   }
 }
#1 lore raw

PATCH 2/3 Don't put modules without dependencies into moddep.lst

ChangeLog:

* genmoddep.awk: Don't output lines that contain to dependencies.
---

 genmoddep.awk |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
genmoddep.awk +3 -1
index db8e07e..1bdf7f1 100644
@@ -66,6 +66,8 @@ END {
     for (depmod in uniqmods) {
       modlist = modlist " " depmod;
     }
-    printf "%s:%s\n", mod, modlist >ENVIRON["MODDEP"];
+    if (modlist != "") {
+      printf "%s:%s\n", mod, modlist >ENVIRON["MODDEP"];
+    }
   }
 }
#2 lore raw

Re: [PATCH 2/3] Don't put modules without dependencies into moddep.lst

Quoted 1 line · Pavel Roskin

+ if (modlist != "") {

Are you sure this does what you expect? I read it as "compare this char * with this const char *", which will always return false.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#3 lore raw

Re: [PATCH 2/3] Don't put modules without dependencies into moddep.lst

Quoting Robert Millan <[email protected]>:

Quoted 5 lines · Pavel Roskin
Quoted 1 line

+ if (modlist != "") {

Are you sure this does what you expect? I read it as "compare this char * with this const char *", which will always return false.

Yes, this check does the right thing. And we do the same thing elsewhere:

if (depmod != "kernel" && depmod != mod)

Even the gawk info page has it:

if ($(NF+1) != "")

It works with POSIXLY_CORRECT too.

Signature · 2 lines
Regards,
Pavel Roskin
#4 lore raw

Re: [PATCH 2/3] Don't put modules without dependencies into moddep.lst

Quoted 5 lines · Pavel Roskin

Quoting Robert Millan <[email protected]>:

Quoted 3 lines · Pavel Roskin
Quoted 1 line

+ if (modlist != "") {

Quoted 8 lines
Quoted 2 lines

Are you sure this does what you expect? I read it as "compare this char * with this const char *", which will always return false.

Yes, this check does the right thing. And we do the same thing elsewhere:

if (depmod != "kernel" && depmod != mod)

Even the gawk info page has it:

Oh, I thought you were writing C.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#5 lore raw

PATCH 3/3 Use ELF symbols without "32" or "64"

In reply to Pavel Roskin

ChangeLog:

* include/grub/elf.h: Define Elf_Sword and Elf_Xword.
* kern/i386/dl.c: Use ELF symbols without "32" or "64".
* kern/powerpc/dl.c: Likewise.
* kern/sparc64/dl.c: Likewise.
* kern/x86_64/dl.c: Likewise.
---

 include/grub/elf.h |    4 ++++
 kern/i386/dl.c     |   34 +++++++++++++++++-----------------
 kern/powerpc/dl.c  |   42 +++++++++++++++++++++---------------------
 kern/sparc64/dl.c  |   46 +++++++++++++++++++++++-----------------------
 kern/x86_64/dl.c   |    6 +++---
 5 files changed, 68 insertions(+), 64 deletions(-)
include/grub/elf.h +4 -0
index 49570a6..1a1ec13 100644
@@ -2340,8 +2340,10 @@ typedef Elf32_Rel Elf_Rel;
 typedef Elf32_Rela Elf_Rela;
 typedef Elf32_Section Elf_Section;
 typedef Elf32_Shdr Elf_Shdr;
+typedef Elf32_Sword Elf_Sword;
 typedef Elf32_Sym Elf_Sym;
 typedef Elf32_Word Elf_Word;
+typedef Elf32_Xword Elf_Xword;
 
 #define ELF_ST_BIND(val)	ELF32_ST_BIND(val)
 #define ELF_ST_TYPE(val)	ELF32_ST_TYPE(val)
@@ -2359,8 +2361,10 @@ typedef Elf64_Rel Elf_Rel;
 typedef Elf64_Rela Elf_Rela;
 typedef Elf64_Section Elf_Section;
 typedef Elf64_Shdr Elf_Shdr;
+typedef Elf64_Sword Elf_Sword;
 typedef Elf64_Sym Elf_Sym;
 typedef Elf64_Word Elf_Word;
+typedef Elf64_Xword Elf_Xword;
 
 #define ELF_ST_BIND(val)	ELF64_ST_BIND (val)
 #define ELF_ST_TYPE(val)	ELF64_ST_TYPE (val)
kern/i386/dl.c +17 -17
index a17f175..91121f6 100644
@@ -26,7 +26,7 @@
 grub_err_t
 grub_arch_dl_check_header (void *ehdr)
 {
-  Elf32_Ehdr *e = ehdr;
+  Elf_Ehdr *e = ehdr;
 
   /* Check the magic numbers.  */
   if (e->e_ident[EI_CLASS] != ELFCLASS32
@@ -41,15 +41,15 @@ grub_arch_dl_check_header (void *ehdr)
 grub_err_t
 grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
 {
-  Elf32_Ehdr *e = ehdr;
-  Elf32_Shdr *s;
-  Elf32_Word entsize;
+  Elf_Ehdr *e = ehdr;
+  Elf_Shdr *s;
+  Elf_Word entsize;
   unsigned i;
 
   /* Find a symbol table.  */
-  for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff);
+  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
        i < e->e_shnum;
-       i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize))
+       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
     if (s->sh_type == SHT_SYMTAB)
       break;
 
@@ -58,9 +58,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
 
   entsize = s->sh_entsize;
 
-  for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff);
+  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
        i < e->e_shnum;
-       i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize))
+       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
     if (s->sh_type == SHT_REL)
       {
 	grub_dl_segment_t seg;
@@ -72,32 +72,32 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
 
 	if (seg)
 	  {
-	    Elf32_Rel *rel, *max;
+	    Elf_Rel *rel, *max;
 
-	    for (rel = (Elf32_Rel *) ((char *) e + s->sh_offset),
+	    for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
 		   max = rel + s->sh_size / s->sh_entsize;
 		 rel < max;
 		 rel++)
 	      {
-		Elf32_Word *addr;
-		Elf32_Sym *sym;
+		Elf_Word *addr;
+		Elf_Sym *sym;
 
 		if (seg->size < rel->r_offset)
 		  return grub_error (GRUB_ERR_BAD_MODULE,
 				     "reloc offset is out of the segment");
 
-		addr = (Elf32_Word *) ((char *) seg->addr + rel->r_offset);
-		sym = (Elf32_Sym *) ((char *) mod->symtab
-				     + entsize * ELF32_R_SYM (rel->r_info));
+		addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
+		sym = (Elf_Sym *) ((char *) mod->symtab
+				     + entsize * ELF_R_SYM (rel->r_info));
 
-		switch (ELF32_R_TYPE (rel->r_info))
+		switch (ELF_R_TYPE (rel->r_info))
 		  {
 		  case R_386_32:
 		    *addr += sym->st_value;
 		    break;
 
 		  case R_386_PC32:
-		    *addr += (sym->st_value - (Elf32_Word) seg->addr
+		    *addr += (sym->st_value - (Elf_Word) seg->addr
 			      - rel->r_offset);
 		    break;
 		  }
kern/powerpc/dl.c +21 -21

109 lines not on this page · raw message

kern/sparc64/dl.c +23 -23

112 lines not on this page · raw message

kern/x86_64/dl.c +3 -3
index 9e5de6e..73a7337 100644
@@ -90,9 +90,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
 		addr32 = (Elf64_Word *) ((char *) seg->addr + rel->r_offset);
 		addr64 = (Elf64_Xword *) addr32;
 		sym = (Elf64_Sym *) ((char *) mod->symtab
-				     + entsize * ELF64_R_SYM (rel->r_info));
+				     + entsize * ELF_R_SYM (rel->r_info));
 
-		switch (ELF64_R_TYPE (rel->r_info))
+		switch (ELF_R_TYPE (rel->r_info))
 		  {
 		  case R_X86_64_64:
 		    *addr64 += rel->r_addend + sym->st_value;
@@ -109,7 +109,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
                     break;
 
                   default:
-                    grub_fatal ("Unrecognized relocation: %d\n", ELF64_R_TYPE (rel->r_info));
+                    grub_fatal ("Unrecognized relocation: %d\n", ELF_R_TYPE (rel->r_info));
 		  }
 	      }
 	  }
#6 lore raw
In reply to Pavel Roskin

Hi,

Perhaps you could also take a look at my previous patch

[PATCH] Use symbol database to maintain module dependence

It add a program grub-symdb to maintain symbol database and therefore eliminate def- and unf- files, it also allows incremental build.

Quoted 161 lines · Pavel Roskin

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(-)
Makefile.in +0 -0
index f82566a..e6be9c4 100644
@@ -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

Makefile.in +2 -4
-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 > $@

genmk.rb +1 -2
index e3866c1..2883362 100644
@@ -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)

genmk.rb +4 -2
@@ -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

genmk.rb +0 -4
-#{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')

genmoddep.awk +24 -15
index f7f085e..db8e07e 100644
@@ -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"];
   }
  }

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 1 line
Bean
#7 lore raw

Quoting Bean <[email protected]>:

Quoted 6 lines

Perhaps you could also take a look at my previous patch

[PATCH] Use symbol database to maintain module dependence

It add a program grub-symdb to maintain symbol database and therefore eliminate def- and unf- files, it also allows incremental build.

grub-symdb would need to be compiled by a native C compiler. Otherwise, it won't work when cross-compiling the utilities.

It's not that it's a big deal per se, but it is will add complexity if we try to use autoconf to look for it.

Adding grub-symdb to bin_UTILITIES would result in it being installed along with the utilities that are actually used after the build. I think it's wrong. Temporary build tools don't belong there.

I think awk is a better choice than native C, as it's assumed to be available on the build system. I could rewrite genmoddep.awk in shell script, if we want to eliminate awk from the build. But I'm not sure every shell would handle the needed amount of environment variables to emulate arrays. And it would be almost certainly slower.

The awk script could be changed to run nm and to parse output of different kinds on nm. We could probably remove another Apple hack from the makefiles by having awk do the parsing.

I think we could specify the dependencies manually and have the script check them rather than generate them. That would mean that no dependencies will be created unknowingly. Chances are it will allow more incremental builds.

Going offtopic, another approach to avoid massive rebuilds for minor changes would be to ban most typedefs, so that we can use forward declarations for structures instead of including files that are otherwise unneeded (fresh example: dl.h including elf.h just to use a pointer to the structure).

Signature · 2 lines
Regards,
Pavel Roskin
#8 lore raw
Quoted 12 lines · Pavel Roskin

Quoting Bean <[email protected]>:

Quoted 6 lines

Perhaps you could also take a look at my previous patch

[PATCH] Use symbol database to maintain module dependence

It add a program grub-symdb to maintain symbol database and therefore eliminate def- and unf- files, it also allows incremental build.

grub-symdb would need to be compiled by a native C compiler.  Otherwise, it won't work when cross-compiling the utilities.

Quoted 6 lines

It's not that it's a big deal per se, but it is will add complexity if we try to use autoconf to look for it.

Adding grub-symdb to bin_UTILITIES would result in it being installed along with the utilities that are actually used after the build.  I think it's wrong.  Temporary build tools don't belong there.

Hi,

Actually, that's the intention. grub-symdb and the symbol database is supposed to be installed in the target system. They can be used to support external grub modules. To install new package, we can just copy the modules files and use rerun grub-symdb to update the database.

Quoted 10 lines

I think awk is a better choice than native C, as it's assumed to be available on the build system.  I could rewrite genmoddep.awk in shell script, if we want to eliminate awk from the build.  But I'm not sure every shell would handle the needed amount of environment variables to emulate arrays.  And it would be almost certainly slower.

The awk script could be changed to run nm and to parse output of different kinds on nm.  We could probably remove another Apple hack from the makefiles by having awk do the parsing.

With grub-symdb, there is no need to relied on nm, I think this would make it more portable.

Quoted 4 lines

I think we could specify the dependencies manually and have the script check them rather than generate them.  That would mean that no dependencies will be created unknowingly.  Chances are it will allow more incremental builds.

With the build system, there is a lot of unnecessary rebuilds, as it relies on a central moddep.lst:

pre-*.o => moddep.lst => mod-*.c => *.mod

As you can see, modification to any source file would cause all the modules files to be rebuild. Although for most of them, it's only the trunk, but there is still a lot of necessary work.

Signature · 1 line
Bean
#9 lore raw

Quoting Bean <[email protected]>:

Quoted 20 lines · Pavel Roskin
Quoted 12 lines

Quoting Bean <[email protected]>:

Quoted 6 lines

Perhaps you could also take a look at my previous patch

[PATCH] Use symbol database to maintain module dependence

It add a program grub-symdb to maintain symbol database and therefore eliminate def- and unf- files, it also allows incremental build.

grub-symdb would need to be compiled by a native C compiler.  Otherwise, it won't work when cross-compiling the utilities.

Quoted 6 lines

It's not that it's a big deal per se, but it is will add complexity if we try to use autoconf to look for it.

Adding grub-symdb to bin_UTILITIES would result in it being installed along with the utilities that are actually used after the build.  I think it's wrong.  Temporary build tools don't belong there.

Quoted 7 lines

Hi,

Actually, that's the intention. grub-symdb and the symbol database is supposed to be installed in the target system. They can be used to support external grub modules. To install new package, we can just copy the modules files and use rerun grub-symdb to update the database.

Oh, I see! I'll need to take a closer look.

Quoted 8 lines

With the build system, there is a lot of unnecessary rebuilds, as it relies on a central moddep.lst:

pre-*.o => moddep.lst => mod-*.c => *.mod

As you can see, modification to any source file would cause all the modules files to be rebuild. Although for most of them, it's only the trunk, but there is still a lot of necessary work.

Then moddep.lst should not be touched if the result is the same. That shouldn't be hard to do.

Signature · 2 lines
Regards,
Pavel Roskin
#10 lore raw
In reply to Bean
Quoted 20 lines · Bean
Quoted 12 lines · Pavel Roskin

Quoting Bean <[email protected]>:

Quoted 6 lines

Perhaps you could also take a look at my previous patch

[PATCH] Use symbol database to maintain module dependence

It add a program grub-symdb to maintain symbol database and therefore eliminate def- and unf- files, it also allows incremental build.

grub-symdb would need to be compiled by a native C compiler.  Otherwise, it won't work when cross-compiling the utilities.

Quoted 6 lines

It's not that it's a big deal per se, but it is will add complexity if we try to use autoconf to look for it.

Adding grub-symdb to bin_UTILITIES would result in it being installed along with the utilities that are actually used after the build.  I think it's wrong.  Temporary build tools don't belong there.

Quoted 7 lines

Hi,

Actually, that's the intention. grub-symdb and the symbol database is supposed to be installed in the target system. They can be used to support external grub modules. To install new package, we can just copy the modules files and use rerun grub-symdb to update the database.

I tend to agree with Pavel. We should be careful about adding complexity, and only do it when we're sure it's going to pay off.

(I'm not saying it doesn't pay off here, but this factor should always be taken into account IMO)

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."