On Wed, Apr 03, 2002 at 04:26:21PM -0800, David E. O'Brien wrote:
> obrien      2002/04/03 16:26:21 PST
> 
>   Modified files:
>     gnu/usr.bin/cc/cc1   Makefile 
>     gnu/usr.bin/cc/cc1obj Makefile 
>     gnu/usr.bin/cc/cc1plus Makefile 
>   Log:
>   Clean up the YACCing.  I don't know why we cannot leave the .y's as .y's.
>   So lets see if doing so causes anyone trouble.
>   Also use make(1)'s assistance in using the right file.  It knows the
>   dependency, so lets just ask it.
>   
>   Revision  Changes    Path
>   1.20      +3 -5      src/gnu/usr.bin/cc/cc1/Makefile
>   1.14      +2 -4      src/gnu/usr.bin/cc/cc1obj/Makefile
>   1.23      +2 -2      src/gnu/usr.bin/cc/cc1plus/Makefile
> 
Yes it does cause trouble.

%%%
 c-parse.c c-parse.h: c-parse.in
        sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
            -e "/^ifc$$/d" -e "/^end ifc$$/d" \
-           ${GCCDIR}/c-parse.in > c-parse.y
+           ${.ALLSRC} > c-parse.y
        ${YACC} -d -o c-parse.c c-parse.y
-       mv c-parse.y c-parse.y.out
%%%

c-parse.c depends on c-parse.y (due to the standard .y.c: rule) and
${.ALLSRC} becomes "c-parse.in c-parse.y" in this case.  If c-parse.y
already exists but is stale, this results in sed(1) flooding your
entire ${.OBJDIR} disk with c-parse.c.  This created a 3G file on my
machine that had the time set incorrectly.  Here's the how-to-repeat:

: # pwd
: /usr/src/gnu/usr.bin/cc/cc1
: # make cleandir
: # make cleandir
: rm -f c-parse.c c-parse.h c-parse.y cc1 c-parse.o c-lang.o c-decl.o c-lex.o
: rm -f .depend /usr/src/gnu/usr.bin/cc/cc1/GPATH /usr/src/gnu/usr.bin/cc/cc
: 1/GRTAGS  /usr/src/gnu/usr.bin/cc/cc1/GSYMS /usr/src/gnu/usr.bin/cc/cc1/GT
: AGS
: # touch c-parse.y
: # make -n c-parse.c
: sed -e "/^ifobjc$/,/^end ifobjc$/d"  -e "/^ifc$/d"  -e "/^end ifc$/d"  /usr/src/gn
: u/usr.bin/cc/cc1/../../../../contrib/gcc.295/c-parse.in c-parse.y > c-parse.y
                                                          ^^^^^^^^^^^^^^^^^^^^^
: yacc -d -o c-parse.c c-parse.y

While backing out these changes would be an option, below is the correct fix.

While working on the fix in cc1obj, I also fixed the bug in bsd.prog.mk
and bsd.lib.mk (committed now); cc1obj/Makefile has "../cc_tools" in the
.PATH list, and this caused .if exists(${DEPENDFILE}) in bsd.prog.mk to
match "../cc_tools/.depend" and miss the (needed in this case) dependency
of ${OBJS} on ${SRCS:M*.h}.  In anycase, ../cc_tools is not needed here
so I removed it.

While grep(1)ping for the "\.PATH.*\.\." under the gnu/usr.bin/cc, I
noticed that you forgot to "cvs rm" cc_drv/Makefile -- it's no longer
needed as of gnu/usr.bin/cc/Makefile,v 1.21.

I have also cleaned up cc1plus/Makefile (with some black magic) to avoid
redefining standard yacc build rules.

Here's the complete patch:

%%%
Index: cc1/Makefile
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/cc/cc1/Makefile,v
retrieving revision 1.23
diff -u -r1.23 Makefile
--- cc1/Makefile        4 Apr 2002 19:26:12 -0000       1.23
+++ cc1/Makefile        7 Apr 2002 16:15:04 -0000
@@ -2,10 +2,10 @@
 
 .include "../Makefile.inc"
 
-.PATH: ../cc_tools ${GCCDIR}
+.PATH: ${GCCDIR}
  
 PROG=  cc1
-SRCS=  c-parse.c c-parse.h c-lang.c
+SRCS=  c-parse.y c-lang.c
 # Ugh, compiled twice...
 SRCS+= c-decl.c c-lex.c
 BINDIR=        /usr/libexec
@@ -19,15 +19,13 @@
 
 #-----------------------------------------------------------------------
 # C parser
-.ORDER: c-parse.c c-parse.h
-c-parse.c c-parse.h: c-parse.in
+c-parse.y: c-parse.in
        sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
            -e "/^ifc$$/d" \
            -e "/^end ifc$$/d" \
            ${.ALLSRC} > c-parse.y
-       ${YACC} -d -o c-parse.c c-parse.y
 
-CLEANFILES+=   c-parse.c c-parse.h c-parse.y           # insurance
+CLEANFILES=    c-parse.y               # insurance
 
 #-----------------------------------------------------------------------
 
Index: cc1obj/Makefile
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/cc/cc1obj/Makefile,v
retrieving revision 1.17
diff -u -r1.17 Makefile
--- cc1obj/Makefile     4 Apr 2002 19:26:13 -0000       1.17
+++ cc1obj/Makefile     7 Apr 2002 16:15:04 -0000
@@ -2,10 +2,10 @@
 
 .include "../Makefile.inc"
 
-.PATH: ../cc_tools ${GCCDIR}/objc ${GCCDIR}
+.PATH: ${GCCDIR}/objc ${GCCDIR}
 
 PROG=  cc1obj
-SRCS=  objc-parse.c c-parse.h objc-act.c
+SRCS=  objc-parse.y c-parse.h objc-act.c
 # Ugh, compiled twice...
 SRCS+= c-decl.c c-lex.c
 BINDIR=        /usr/libexec
@@ -19,16 +19,16 @@
 
 #-----------------------------------------------------------------------
 # objc parser
-.ORDER: objc-parse.c c-parse.h
-objc-parse.c c-parse.h: c-parse.in
+objc-parse.y: c-parse.in
        sed -e "/^ifc$$/,/^end ifc$$/d" \
            -e "/^ifobjc$$/d" \
            -e "/^end ifobjc$$/d" \
            ${.ALLSRC} > objc-parse.y
-       ${YACC} -d -o objc-parse.c objc-parse.y
-       mv objc-parse.h c-parse.h
 
-CLEANFILES+=   objc-parse.c c-parse.h objc-parse.y             # insurance
+c-parse.h: objc-parse.h
+       ln -s ${.ALLSRC} ${.TARGET}
+
+CLEANFILES=    c-parse.h objc-parse.y          # insurance
 
 #-----------------------------------------------------------------------
 
Index: cc1plus/Makefile
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/cc/cc1plus/Makefile,v
retrieving revision 1.24
diff -u -r1.24 Makefile
--- cc1plus/Makefile    4 Apr 2002 00:50:14 -0000       1.24
+++ cc1plus/Makefile    7 Apr 2002 16:15:04 -0000
@@ -5,7 +5,7 @@
 .PATH: ${GCCDIR}/cp
 
 PROG=  cc1plus
-SRCS=  parse.c parse.h
+SRCS=  parse.y y.tab.h parse.h
 SRCS+= call.c class.c cvt.c decl.c decl2.c errfn.c error.c except.c expr.c \
        friend.c init.c lex.c method.c pt.c ptree.c repo.c rtti.c \
        search.c semantics.c sig.c spew.c tree.c typeck.c typeck2.c xref.c
@@ -18,12 +18,11 @@
 DPADD+=        ${LIBCC_INT} 
 LDADD+=        ${LIBCC_INT}
 
-.ORDER: parse.c parse.h
-parse.c parse.h: parse.y
-       ${YACC} -d -o parse.c ${.ALLSRC}
-       grep '^#define[   ]*YYEMPTY' parse.c >>parse.h
+parse.h: y.tab.h parse.c
+       cp y.tab.h ${.TARGET}
+       grep '^#define[   ]*YYEMPTY' parse.c >>${.TARGET}
 
-CLEANFILES+=   parse.c parse.h
+CLEANFILES=    parse.h
 
 CPPHDRS=       exception new new.h typeinfo
 
Index: cc_drv/Makefile
===================================================================
RCS file: cc_drv/Makefile
diff -N cc_drv/Makefile
--- cc_drv/Makefile     24 Jan 2000 08:44:30 -0000      1.11
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-# $FreeBSD: src/gnu/usr.bin/cc/cc_drv/Makefile,v 1.11 2000/01/24 08:44:30 obrien Exp $
-
-.include "../Makefile.inc"
-
-.PATH: ../cc_tools ${GCCDIR}
-
-LIB=           cc_drv
-NOPROFILE=     YES
-NOPIC=         YES
-
-SRCS=  multilib.h choose-temp.c obstack.c prefix.c pexecute.c version.c
-
-CFLAGS+=       -DIN_GCC
-
-install:
-       @true
-
-${OUT_OBJ}.o ${OUT_OBJ}.so:    ${OUT_FILE}
-
-.include <bsd.lib.mk>
%%%


Cheers,
-- 
Ruslan Ermilov          Sysadmin and DBA,
[EMAIL PROTECTED]           Sunbay Software AG,
[EMAIL PROTECTED]          FreeBSD committer,
+380.652.512.251        Simferopol, Ukraine

http://www.FreeBSD.org  The Power To Serve
http://www.oracle.com   Enabling The Information Age

Attachment: msg37066/pgp00000.pgp
Description: PGP signature

Reply via email to