This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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 to gcc/Makefile.in for fastcompare* targets [take 2]


Looking at my previous fastcompare* patch:
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00752.html

I observed that the skeleton of the "compare" shell fragments was
identical among the "slow", "gnu" and my new "fast" variant.  There is
no need to repeat it three times.  I merged them all into one to make
it more maintainable by inserting a case stmt inside the for loops to
fork off the appropriate cmp magic based on $@.

Tested by running make gnucompare slowcompare fastcompare and compare
in the gcc directory.  I also tweeked a random .o file to simulate an
error and reran all four targets to ensure they trap the compare
failure.  (They did.)

I used a context diff 'cause it was slightly easier to read than the
unified diff format in this case.

Ok for mainline?

		Thanks,
		--Kaveh


2003-09-11  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* Makefile.in (gnucompare*): Merge into ...
	(slowcompare*): ... here.
	(fastcompare*): New targets.
	* aclocal.m4 (gcc_AC_PROG_CMP_IGNORE_INITIAL): Add checks for
	other "fast" cmp programs.
	* configure: Regenerate.

diff -rcp orig/egcc-CVS20030919/gcc/Makefile.in egcc-CVS20030919/gcc/Makefile.in
*** orig/egcc-CVS20030919/gcc/Makefile.in	Sun Sep 14 20:00:59 2003
--- egcc-CVS20030919/gcc/Makefile.in	Sat Sep 20 00:47:03 2003
*************** restrap:
*** 3529,3590 ****
  	$(MAKE) unstrap
  	$(MAKE) $(REMAKEFLAGS) bootstrap
  
! # Compare the object files in the current directory with those in the
! # stage2 directory.
! # ./ avoids bug in some versions of tail.
! slowcompare slowcompare3 slowcompare4 slowcompare-lean slowcompare3-lean slowcompare4-lean: force
  	-rm -f .bad_compare
! 	case "$@" in slowcompare | slowcompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^slowcompare\([0-9][0-9]*\).*,\1,'` ;; esac; \
  	for file in *$(objext); do \
! 	  tail +16c ./$$file > tmp-foo1; \
! 	  tail +16c stage$$stage/$$file > tmp-foo2 \
! 	    && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \
! 	done
! 	case "$@" in slowcompare | slowcompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^slowcompare\([0-9][0-9]*\).*,\1,'` ;; esac; \
! 	for dir in tmp-foo $(SUBDIRS); do \
! 	  if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \
! 	    for file in $$dir/*$(objext); do \
  	      tail +16c ./$$file > tmp-foo1; \
  	      tail +16c stage$$stage/$$file > tmp-foo2 \
  	        && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \
! 	    done; \
! 	  else true; fi; \
! 	done
! 	-rm -f tmp-foo*
! 	case "$@" in slowcompare | slowcompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^slowcompare\([0-9][0-9]*\).*,\1,'` ;; esac; \
! 	if [ -f .bad_compare ]; then \
! 	  echo "Bootstrap comparison failure!"; \
! 	  cat .bad_compare; \
! 	  exit 1; \
! 	else \
! 	  case "$@" in \
! 	    *-lean ) rm -rf stage$$stage ;; \
! 	    *) ;; \
! 	  esac; true; \
! 	fi
! 
! # Compare the object files in the current directory with those in the
! # stage2 directory.  Use gnu cmp (diffutils v2.4 or later) to avoid
! # running tail and the overhead of twice copying each object file.
! # An exit status of 1 is precisely the result we're looking for (other
! # values mean other problems).
! gnucompare gnucompare3 gnucompare4 gnucompare-lean gnucompare3-lean gnucompare4-lean: force
! 	-rm -f .bad_compare
! 	case "$@" in gnucompare | gnucompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^gnucompare\([0-9][0-9]*\).*,\1,'` ;; esac; \
! 	for file in *$(objext); do \
! 	  cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \
! 	  test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
  	done
! 	case "$@" in gnucompare | gnucompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^gnucompare\([0-9][0-9]*\).*,\1,'` ;; esac; \
  	for dir in tmp-foo $(SUBDIRS); do \
  	  if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \
  	    for file in $$dir/*$(objext); do \
! 	      cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \
! 	      test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
  	    done; \
  	  else true; fi; \
  	done
! 	case "$@" in gnucompare | gnucompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^gnucompare\([0-9][0-9]*\).*,\1,'` ;; esac; \
  	if [ -f .bad_compare ]; then \
  	  echo "Bootstrap comparison failure!"; \
  	  cat .bad_compare; \
--- 3529,3590 ----
  	$(MAKE) unstrap
  	$(MAKE) $(REMAKEFLAGS) bootstrap
  
! # These targets compare the object files in the current directory with
! # those in a stage directory.  We need to skip the first N bytes of
! # each object file.  The "slow" mechanism assumes nothing special
! # about cmp and uses the tail command to skip.  ./ avoids a bug in
! # some versions of tail.  The "gnu" targets use gnu cmp (diffutils
! # v2.4 or later), to avoid running tail and the overhead of twice
! # copying each object file.  Likewise, the "fast" targets use the skip
! # parameter of cmp available on some systems to accomplish the same
! # thing.  An exit status of 1 is precisely the result we're looking
! # for (other values mean other problems).
! slowcompare slowcompare3 slowcompare4 slowcompare-lean slowcompare3-lean slowcompare4-lean \
! fastcompare fastcompare3 fastcompare4 fastcompare-lean fastcompare3-lean fastcompare4-lean \
!  gnucompare  gnucompare3  gnucompare4  gnucompare-lean  gnucompare3-lean  gnucompare4-lean: force
  	-rm -f .bad_compare
! 	case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \
  	for file in *$(objext); do \
! 	  case "$@" in \
! 	    slowcompare* ) \
  	      tail +16c ./$$file > tmp-foo1; \
  	      tail +16c stage$$stage/$$file > tmp-foo2 \
  	        && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \
! 	      ;; \
! 	    fastcompare* ) \
! 	      cmp $$file stage$$stage/$$file 16 16 > /dev/null 2>&1; \
! 	      test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
! 	      ;; \
! 	    gnucompare* ) \
! 	      cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \
! 	      test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
! 	      ;; \
! 	  esac ; \
  	done
! 	case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \
  	for dir in tmp-foo $(SUBDIRS); do \
  	  if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \
  	    for file in $$dir/*$(objext); do \
! 	      case "$@" in \
! 		slowcompare* ) \
! 		  tail +16c ./$$file > tmp-foo1; \
! 		  tail +16c stage$$stage/$$file > tmp-foo2 \
! 		    && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \
! 		  ;; \
! 		fastcompare* ) \
! 		  cmp $$file stage$$stage/$$file 16 16 > /dev/null 2>&1; \
! 		  test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
! 		  ;; \
! 		gnucompare* ) \
! 		  cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \
! 		  test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
! 		  ;; \
! 	      esac ; \
  	    done; \
  	  else true; fi; \
  	done
! 	-rm -f tmp-foo*
! 	case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \
  	if [ -f .bad_compare ]; then \
  	  echo "Bootstrap comparison failure!"; \
  	  cat .bad_compare; \
*************** gnucompare gnucompare3 gnucompare4 gnuco
*** 3592,3597 ****
--- 3592,3598 ----
  	else \
  	  case "$@" in \
  	    *-lean ) rm -rf stage$$stage ;; \
+ 	    *) ;; \
  	  esac; true; \
  	fi
  
diff -rcp orig/egcc-CVS20030919/gcc/aclocal.m4 egcc-CVS20030919/gcc/aclocal.m4
*** orig/egcc-CVS20030919/gcc/aclocal.m4	Tue Aug 12 20:01:43 2003
--- egcc-CVS20030919/gcc/aclocal.m4	Sat Sep 20 00:41:12 2003
*************** fi
*** 104,122 ****
  dnl 'make compare' can be significantly faster, if cmp itself can
  dnl skip bytes instead of using tail.  The test being performed is
  dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
! dnl but we need to sink errors and handle broken shells.
  AC_DEFUN(gcc_AC_PROG_CMP_IGNORE_INITIAL,
  [AC_CACHE_CHECK([for cmp's capabilities], gcc_cv_prog_cmp_skip,
  [ echo abfoo >t1
    echo cdfoo >t2
    if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
      if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
!       gcc_cv_prog_cmp_skip=slowcompare
      else
        gcc_cv_prog_cmp_skip=gnucompare
      fi
!   else
!     gcc_cv_prog_cmp_skip=slowcompare
    fi
    rm t1 t2
  ])
--- 104,132 ----
  dnl 'make compare' can be significantly faster, if cmp itself can
  dnl skip bytes instead of using tail.  The test being performed is
  dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
! dnl but we need to sink errors and handle broken shells.  We also test
! dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
! dnl accepted by cmp on some systems.
  AC_DEFUN(gcc_AC_PROG_CMP_IGNORE_INITIAL,
  [AC_CACHE_CHECK([for cmp's capabilities], gcc_cv_prog_cmp_skip,
  [ echo abfoo >t1
    echo cdfoo >t2
+   gcc_cv_prog_cmp_skip=slowcompare
    if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
      if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
!       :
      else
        gcc_cv_prog_cmp_skip=gnucompare
      fi
!   fi
!   if test $gcc_cv_prog_cmp_skip = slowcompare ; then
!     if cmp t1 t2 2 2 > /dev/null 2>&1; then
!       if cmp t1 t2 1 1 > /dev/null 2>&1; then
!         :
!       else
!         gcc_cv_prog_cmp_skip=fastcompare
!       fi
!     fi
    fi
    rm t1 t2
  ])


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