This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2 roland/sysd-rules] Rewrite sysd-rules generation using an awk script.


This replaces the sysd-rules generation code done in sh directly in
Makerules with a separate awk script.  It's intended to behave exactly
the same as the old code does, except that inhibit-sysdep-asm now uses
regexps instead of glob patterns.  (The inhibit-sysdep-asm support has
actually been broken for quite a while and it doesn't happen to matter
any more for the Hurd.  This restores it, in case it comes to matter
again.)  The awk script is at least somewhat easier to hack.

I've verified that the results for an x86_64-linux-gnu configuration are
the same as before.

I'm not committing this right away mainly because the reason for it is
the next patch, which has more issues.  But also it's possible there is
some regression affecting some other configuration.  Please test
whatever configurations you can, by doing:

	# get a build started before the patch
	$ mv sysd-rules sysd-rules.save
	# apply the patch or do 'git checkout roland/sysd-rules~1'
	$ make # only need to let it get as far as building sysd-rules
	$ diff -u sysd-rules{.save,}

Your diff should be nothing but this:

	-sysd-rules-done = t
	+sysd-rules-done := t

If you have any other differences at all, tell me all about it.


Thanks,
Roland


2013-06-13  Roland McGrath  <roland@hack.frob.com>

	* Makerules [inhibit-sysdep-asm] (check-inhibit-asm): Variable removed.
	($(common-objpfx)sysd-rules): Replace shell logic with running ...
	* scripts/sysd-rules.awk: ... this new script.
	* sysdeps/mach/hurd/Makefile (inhibit-sysdep-asm): Use a regexp rather
	than a glob-style pattern.

--- a/Makerules
+++ b/Makerules
@@ -217,14 +217,9 @@ endif
 # later directory would be chosen over a .c file in an earlier directory,
 # which does not preserve the desired sysdeps ordering behavior.
 
-# System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
-# patterns matching sysdep directories whose assembly source files should
-# be suppressed.
-ifdef inhibit-sysdep-asm
-define check-inhibit-asm
-case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) asm= ;; esac;
-endef
-endif
+# System-dependent makefiles can put in `inhibit-sysdep-asm' regexps
+# matching sysdep directories whose assembly source files should be
+# suppressed.
 
 -include $(common-objpfx)sysd-rules
 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
@@ -233,34 +228,16 @@ ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
 sysd-rules-force = FORCE
 FORCE:
 endif
-$(common-objpfx)sysd-rules: $(common-objpfx)config.make $(..)Makerules \
+$(common-objpfx)sysd-rules: $(..)scripts/sysd-rules.awk \
+			    $(common-objpfx)config.make $(..)Makerules \
 			    $(sysdep-makefiles) $(sysdep-makeconfigs) \
 			    $(sysd-rules-force)
 	-@rm -f $@T
-	(echo 'sysd-rules-sysdirs := $(config-sysdirs)';		      \
-	 for dir in $(config-sysdirs); do				      \
-	   case "$$dir" in						      \
-	   /*) ;;							      \
-	   *) dir="\$$(..)$$dir" ;;					      \
-	   esac;							      \
-	   asm='.S';							      \
-	   $(check-inhibit-asm)						      \
-	   for o in $(all-object-suffixes); do				      \
-	     set $(subst :, ,$(sysd-rules-patterns));			      \
-	     while [ $$# -ge 2 ]; do					      \
-	       t=$$1; shift; 						      \
-	       d=$$1; shift;						      \
-	       v=$${t%%%}; [ x"$$v" = x ] || v="\$$($${v}CPPFLAGS)";	      \
-	       for s in $$asm .c; do					      \
-		 echo "\$$(objpfx)$$t$$o: $$dir/$$d$$s \$$(before-compile)";  \
-		 echo "	\$$(compile-command$$s) $$v";			      \
-	       done;							      \
-	     done;							      \
-	   done;							      \
-	   echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force)";	      \
-	   echo "	\$$(do-install)"; 				      \
-	 done;								      \
-	 echo 'sysd-rules-done = t') > $@T
+	LC_ALL=C $(AWK) -f $< > $@T \
+		 	-v all_object_suffixes='$(all-object-suffixes)' \
+		 	-v inhibit_sysdep_asm='$(inhibit-sysdep-asm)' \
+			-v sysd_rules_patterns='$(sysd-rules-patterns)' \
+			-v config_sysdirs='$(config-sysdirs)'
 	mv -f $@T $@
 
 ifndef sysd-rules-done
--- /dev/null
+++ b/scripts/sysd-rules.awk
@@ -0,0 +1,60 @@
+# This is a GAWK script to generate the sysd-rules file.
+# It does not read any input, but it requires that several variables
+# be set on its command line (using -v) to their makefile counterparts:
+#	all_object_suffixes	$(all-object-suffixes)
+#	inhibit_sysdep_asm	$(inhibit-sysdep-asm)
+#	config_sysdirs		$(config_sysdirs)
+#	sysd_rules_patterns	$(sysd-rules-patterns)
+
+BEGIN {
+  print "sysd-rules-sysdirs :=", config_sysdirs;
+
+  nsuffixes = split(all_object_suffixes, suffixes);
+  ninhibit_asm = split(inhibit_sysdep_asm, inhibit_asm);
+  nsysdirs = split(config_sysdirs, sysdirs);
+  npatterns = split(sysd_rules_patterns, patterns);
+
+  for (sysdir_idx = 1; sysdir_idx <= nsysdirs; ++sysdir_idx) {
+    dir = sysdirs[sysdir_idx];
+    if (dir !~ /^\//) dir = "$(..)" dir;
+    asm_rules = 1;
+    for (i = 1; i <= ninhibit_asm; ++i) {
+      if (dir ~ ("^.*sysdeps/" inhibit_asm[i] "$")) {
+        asm_rules = 0;
+        break;
+      }
+    }
+    for (suffix_idx = 1; suffix_idx <= nsuffixes; ++suffix_idx) {
+      o = suffixes[suffix_idx];
+      for (pattern_idx = 1; pattern_idx <= npatterns; ++pattern_idx) {
+        pattern = patterns[pattern_idx];
+        if (split(pattern, td, ":") != 2) {
+          print "bad sysd-rules-patterns element '" pattern "'" > "/dev/stderr";
+          exit 2;
+        }
+        target_pattern = td[1];
+        dep_pattern = td[2];
+        if (target_pattern == "%") {
+          command_suffix = "";
+        } else {
+          prefix = gensub(/%/, "", "", target_pattern);
+          command_suffix = " $(" prefix  "CPPFLAGS)";
+        }
+        target = "$(objpfx)" target_pattern o ":";
+        if (asm_rules) {
+          dep = dir "/" dep_pattern ".S";
+          print target, dep, "$(before-compile)";
+          print "\t$(compile-command.S)" command_suffix;
+        }
+        dep = dir "/" dep_pattern ".c";
+        print target, dep, "$(before-compile)";
+        print "\t$(compile-command.c)" command_suffix;
+      }
+    }
+    print "$(inst_includedir)/%.h:", dir "/%.h", "$(+force)";
+    print "\t$(do-install)";
+  }
+
+  print "sysd-rules-done := t";
+  exit 0;
+}
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -28,7 +28,7 @@ includes += -I$(..)hurd -I$(common-objpfx)hurd/
 # Do not use any assembly code from sysdeps/unix (and subdirectories).
 # This bypasses all the system call stubs and uses any existing posix or
 # generic C files instead.
-inhibit-sysdep-asm += unix*
+inhibit-sysdep-asm += unix.*
 inhibit-unix-syscalls = yes
 
 # Don't try to generate anything from the installed Unix system and its


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]