This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch]: simplify "make compare" some more
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 6 Dec 2003 16:49:07 -0500 (EST)
- Subject: [patch]: simplify "make compare" some more
The "make compare" targets in GCC have two clauses, one to check for
diffs in the GCC top level directory and another to check all language
subdirs. This has been the case ever since we had these targets all
the way back to gcc-2.6.x. I stared and stared at the code, and while
my shell skills are rusty, there doesn't seem to be any need for this.
And from a maintenance perspective it's cleaner to have just one
clause with the cmp gunk in it.
The only thing I can see is that the SUBDIRS clause wraps itself in:
> for dir in tmp-foo $(SUBDIRS); do \
> if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \
I'm guessing that the for-stmt contains "tmp-foo" in case SUBDIRS is
empty (i.e. --enable-languages=c) so one doesn't get a shell syntax
error. Then the if-stmt is used to see if the wildcard expansion gets
any file matches.
If I'm not mistaken, we can replace "tmp-foo" with "." to handle the
top level directory and then delete the entire first clause. I've
left the if-stmt in place in case there is some obscure reason for
keeping it in.
Tested on sparc-sun-solaris2.7 with --enable-languages=c,objc via
"make compare gnucompare fastcompare slowcompare". Then I tweeked a
top level file and an objc directory file to contain diffs, reran all
the compares and looked to see if it found them. It did. For good
measure, I reconfigured with just "c" to make sure empty SUBDIRS
worked ok too. It did.
Timing tests indicate that the new code is slightly (like 0.4%)
faster, but it's hard to distinguish that from noise.
Although we're in stage3, since this can't break the compiler itself I
thought it would be alright to go in now.
Ok for mainline?
Thanks,
--Kaveh
2003-12-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (compare): Combine toplevel and $(SUBDIRS) cases.
diff -rup orig/egcc-CVS20031205/gcc/Makefile.in egcc-CVS20031205/gcc/Makefile.in
--- orig/egcc-CVS20031205/gcc/Makefile.in Thu Dec 4 20:02:16 2003
+++ egcc-CVS20031205/gcc/Makefile.in Sat Dec 6 15:37:43 2003
@@ -3591,25 +3591,7 @@ fastcompare fastcompare3 fastcompare4 fa
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 \
+ for dir in . $(SUBDIRS); do \
if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \
for file in $$dir/*$(objext); do \
case "$@" in \