preprocess-versions

Roland McGrath roland@frob.com
Thu Mar 14 14:25:00 GMT 2002


The changes below get rid of the pipelines using $(preprocess-versions) in
favor of producing intermediate files.  The reason this is better is that
the pipelines mask the exit status from cpp, so if there were errors your
build would continue happilly but would have used bogus or partial cpp
output to produce the final files.

With this fixed, you immediately get a build error on a fresh build
because abi-versions.h doesn't exist yet when Versions.all is being built.
This causes a real build botch for the Hurd --enable-libio case.
That bug is fixed by this further patch (applied after the larger patch below):


2002-03-14  Roland McGrath  <roland@frob.com>

	* Makerules ($(common-objpfx)Versions.v.i): Depend on abi-versions.h.

--- Makerules.orig	Thu Mar 14 14:22:42 2002
+++ Makerules	Thu Mar 14 14:22:48 2002
@@ -286,6 +286,7 @@
 # See %.v/%.v.i implicit rules in Makeconfig.
 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
 			      $(wildcard $(sysdirs:%=%/Versions)) \
+			      $(common-objpfx)abi-versions.h \
 			      $(sysd-versions-force)
 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
 			       $(common-objpfx)Versions.v \


Unless there are objections, I would like to commit all these changes 
to both branches.  Ok?


Thanks,
Roland



2002-03-14  Roland McGrath  <roland@frob.com>

	* Makeconfig (%.v.i, %.v): New implicit rules.
	(preprocess-versions): Variable removed.
	($(common-objpfx)shlib-versions.v.i): New target giving just the
	shlib-versions input files as dependencies.
	($(common-objpfx)soversions.i): Depend on that instead of the input
	files.  Use it as input instead of using a pipeline.
	(postclean-generated): Append soversions.i, shlib-versions.v, and
	shlib-versions.v.i here.
	* Makerules ($(common-objpfx)Versions.def.v.i): New target giving just
	the Versions.def input files as dependencies.
	($(common-objpfx)Versions.v.i): Likewise for Versions files.
	($(common-objpfx)Versions.all): Depend on that instead of the input
	files.  Use it as input instead of using a pipeline.
	($(common-objpfx)sysd-versions): Likewise with Versions.v.i.
	(postclean-generated): Append those .v and .v.i files here.

Index: Makeconfig
===================================================================
RCS file: /cvs/glibc/libc/Makeconfig,v
retrieving revision 1.265
diff -u -r1.265 Makeconfig
--- Makeconfig	2001/09/12 18:49:45	1.265
+++ Makeconfig	2002/03/14 22:17:01
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1991-2000,01,02 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -731,15 +731,24 @@
 
 ifeq (yes, $(build-shared))
 
-# Commands to put in a pipeline to preprocess a file with # comments
-# %ifdef et al based on config.h settings or other %include'd files.
-define preprocess-versions
-sed '/^[ 	]*#/d;s/^[ 	]*%/#/' \
-| $(CC) -E -undef -I$(common-objdir) -I$(..)include \
-		  -include $(common-objpfx)config.h \
-		  -DASSEMBLER -x assembler-with-cpp - \
-| sed '/^[ 	]*#/d;/^[ 	]*$$/d'
-endef
+# This is a pair of implicit rules to preprocess a file with # comments,
+# %ifdef et al, based on config.h settings or other %include'd files.
+# We use chained rules instead of a pipeline here so that we can properly
+# check the exit status of cpp rather than using its bad output when there
+# is a preprocessing error.  Another rule should depend on the output file
+# `FOO.v', and along with that `FOO.v.i' should be given dependencies
+# listing both its input files, and any header files that it may reference
+# (but no commands).
+%.v.i: $(common-objpfx)config.h
+	sed '/^[ 	]*#/d;s/^[ 	]*%/#/' $(filter-out FORCE %.h,$^) \
+	| $(CC) -E -undef -I$(common-objdir) -I$(..)include \
+		   -include $(common-objpfx)config.h \
+		   -DASSEMBLER -x assembler-with-cpp - \
+		   > $@T
+	mv -f $@T $@
+%.v: %.v.i
+	sed '/^[ 	]*#/d;/^[ 	]*$$/d' $< > $@T
+	mv -f $@T $@
 
 # Process the shlib-versions file, which tells us what shared library
 # version numbers to use when we install shared objects on this system.
@@ -747,28 +756,26 @@
 ifeq ($(sysd-sorted-done),t)
 -include $(common-objpfx)soversions.mk
 ifndef avoid-generated
-$(common-objpfx)soversions.i: $(..)shlib-versions $(..)Makeconfig \
-			      $(wildcard $(patsubst %, $(..)%/shlib-versions,\
-						       $(add-ons) \
-						       $(subdirs))) \
-			      $(common-objpfx)config.make
-	cat $(filter-out $(..)Makeconfig $(common-objpfx)config.make,$^) \
-	| $(preprocess-versions) \
-	| while read conf version setname; do \
-	    test -n "$$version" && \
-	    test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
-		       : "$$conf"` != 0 || continue; \
-	    if test "x$$version" = xDEFAULT; then \
-	      default_setname="$$setname"; \
-	    else \
-	      lib=`echo $$version | sed 's/=.*$$//'`; \
-	      if eval test -z "\$${versioned_$${lib}}"; then \
-		eval versioned_$${lib}=yes; \
-		number=`echo $$version | sed "s/^.*=//"`; \
-		echo $$lib $$number $${setname:-$${default_setname}}; \
-	      fi; \
+$(common-objpfx)shlib-versions.v.i: \
+	$(..)shlib-versions $(wildcard $(patsubst %, $(..)%/shlib-versions,\
+						     $(add-ons) \
+						     $(subdirs)))
+$(common-objpfx)soversions.i: $(common-objpfx)shlib-versions.v
+	while read conf version setname; do \
+	  test -n "$$version" && \
+	  test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
+		     : "$$conf"` != 0 || continue; \
+	  if test "x$$version" = xDEFAULT; then \
+	    default_setname="$$setname"; \
+	  else \
+	    lib=`echo $$version | sed 's/=.*$$//'`; \
+	    if eval test -z "\$${versioned_$${lib}}"; then \
+	      eval versioned_$${lib}=yes; \
+	      number=`echo $$version | sed "s/^.*=//"`; \
+	      echo $$lib $$number $${setname:-$${default_setname}}; \
 	    fi; \
-	  done > $@T; exit 0
+	  fi; \
+	done < $< > $@T; exit 0
 	mv -f $@T $@
 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i
 	(while read lib number setname; do \
@@ -784,7 +791,8 @@
 endif
 endif
 
-postclean-generated += soversions.mk
+postclean-generated += soversions.mk soversions.i \
+		       shlib-versions.v shlib-versions.v.i
 
 # Generate the header containing the names of all shared libraries.
 # We use a stamp file to avoid uncessary recompilations.
Index: Makerules
===================================================================
RCS file: /cvs/glibc/libc/Makerules,v
retrieving revision 1.358
diff -u -r1.358 Makerules
--- Makerules	2001/11/16 01:02:19	1.358
+++ Makerules	2002/03/14 22:17:01
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-1999, 2000,2001 Free Software Foundation, Inc.
+# Copyright (C) 1991-1999,2000,01,02 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -263,35 +263,38 @@
 -include $(common-objpfx)sysd-versions
 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
 common-generated += $(version-maps)
-postclean-generated += sysd-versions Versions.all abi-versions.h
+postclean-generated += sysd-versions Versions.all abi-versions.h \
+		       Versions.def.v.i Versions.def.v Versions.v.i Versions.v
 
 ifndef avoid-generated
 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
 sysd-versions-force = FORCE
 FORCE:
 endif
+# See %.v/%.v.i implicit rules in Makeconfig.
+$(common-objpfx)Versions.def.v.i: $(..)Versions.def \
+				  $(wildcard $(add-ons:%=$(..)%/Versions.def))
 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
 			      $(common-objpfx)soversions.i \
-	                      $(..)Versions.def \
-			      $(wildcard $(add-ons:%=$(..)%/Versions.def))
+			      $(common-objpfx)Versions.def.v
 	{ while read lib version setname; do \
 	    test -z "$$setname" || echo "$$lib : $$setname"; \
 	  done < $(word 2,$^); \
-	  cat $(filter-out $< $(word 2,$^),$^) \
-	  | $(preprocess-versions); \
+	  cat $(word 3,$^); \
 	} | LC_ALL=C $(AWK) -f $< > $@T
 	mv -f $@T $@
+# See %.v/%.v.i implicit rules in Makeconfig.
+$(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
+			      $(wildcard $(sysdirs:%=%/Versions)) \
+			      $(sysd-versions-force)
 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
-			       $(..)scripts/versions.awk \
-			       $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
-			       $(wildcard $(sysdirs:%=%/Versions)) \
-			       $(sysd-versions-force)
+			       $(common-objpfx)Versions.v \
+			       $(..)scripts/versions.awk
 	( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
-	  cat $(filter-out $< $(word 2,$^) $(sysd-versions-force),$^) \
-	  | $(preprocess-versions) \
+	  cat $(word 2,$^) \
 	  | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
 			    -v move_if_change='$(move-if-change)' \
-			    -f $(word 2,$^); \
+			    -f $(word 3,$^); \
 	) > $@T
 	mv -f $@T $@
 endif # avoid-generated



More information about the Libc-hacker mailing list