Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jul 2003 12:12:55 -0700
From:      Tim Kientzle <kientzle@acm.org>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        current@freebsd.org
Subject:   Re: Buildworld /rescue failures in 5.1
Message-ID:  <3F202FB7.8010609@acm.org>
References:  <20030716181354.GA44980@dan.emsphone.com> <20030717074756.B17029@gamplex.bde.org> <20030717123524.T24327@schnell.net> <20030718154832.K21942@gamplex.bde.org> <20030718095946.H29869@schnell.net> <3F183EF9.7020506@acm.org> <20030721084750.GH12996@roark.gnf.org> <3F1C1695.30409@acm.org> <p05210687bb44ba2cd1d7@[128.113.24.47]> <p05210688bb44c9d17c89@[128.113.24.47]> <20030723234415.GE12996@roark.gnf.org> <p0521068abb44d439ecfa@[128.113.24.47]>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------070009000100030605080704
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Garance A Drosihn wrote:
> Wed Jul 23 20:08:06 EDT 2003 Starting make depend
>     in /usr/obj/usr/src/rescue/rescue/usr/src/gnu/usr.bin/gzip
> Wed Jul 23 20:08:07 EDT 2003 Finished make depend
>     in /usr/obj/usr/src/rescue/rescue/usr/src/gnu/usr.bin/gzip
> Wed Jul 23 20:08:09 EDT 2003 Starting make depend
>     in /usr/obj/usr/src/rescue/rescue/usr/src/gnu/usr.bin/tar
> 
> So indeed, that 'make depend' had not finished before the 'make'
> for the object had started.
> 

There's another possibility here:  suppose two copies
of make are running simultaneously and both get to
this sequence at about the same time:

  tar_make:
          (cd $(tar_SRCDIR) && \
                  $(MAKE) $(BUILDOPTS) $(tar_OPTS) depend &&\
                  $(MAKE) $(BUILDOPTS) $(tar_OPTS) $(tar_OBJS))


The first make to run this will start building dependencies.
The second copy will see that ".depend" already exists (note that
bsd.dep.mk builds .depend incrementally) and then go on to the
next step.  Depending on the exact timing, this could result in
an attempt to build the object files with an incomplete '.depend' file.

I wonder if something like the attached patch (which causes .depend
to be created atomically) affects things?

Tim

--------------070009000100030605080704
Content-Type: text/plain;
 name="kientzle_bsd.dep.mk.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="kientzle_bsd.dep.mk.diff"

Index: share/mk/bsd.dep.mk
===================================================================
RCS file: /usr/cvs/FreeBSD-CVS/src/share/mk/bsd.dep.mk,v
retrieving revision 1.41
diff -u -r1.41 bsd.dep.mk
--- share/mk/bsd.dep.mk	3 Jul 2003 11:43:57 -0000	1.41
+++ share/mk/bsd.dep.mk	24 Jul 2003 19:08:11 -0000
@@ -112,25 +112,29 @@
 
 # Different types of sources are compiled with slightly different flags.
 # Split up the sources, and filter out headers and non-applicable flags.
+PID != /bin/sh -c 'echo $$$$'
+
 ${DEPENDFILE}: ${SRCS}
-	rm -f ${DEPENDFILE}
+	rm -f ${DEPENDFILE} ${DEPENDFILE}.${PID}
 .if ${SRCS:M*.[cS]} != ""
-	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
+	${MKDEPCMD} -f ${DEPENDFILE}.${PID} -a ${MKDEP} \
 	    ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
 	    ${.ALLSRC:M*.[cS]}
 .endif
 .if ${SRCS:M*.cc} != "" || ${SRCS:M*.C} != "" || ${SRCS:M*.cpp} != "" || \
     ${SRCS:M*.cxx} != ""
-	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
+	${MKDEPCMD} -f ${DEPENDFILE}.${PID} -a ${MKDEP} \
 	    ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
 	    ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
 .endif
 .if ${SRCS:M*.m} != ""
-	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
+	${MKDEPCMD} -f ${DEPENDFILE}.${PID} -a ${MKDEP} \
 	    ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
 	    ${OBJCFLAGS:M-Wno-import*} \
 	    ${.ALLSRC:M*.m}
 .endif
+	mv ${DEPENDFILE}.${PID} ${DEPENDFILE}
+	rm -f ${DEPENDFILE}.${PID}
 .if target(_EXTRADEPEND)
 _EXTRADEPEND: .USE
 ${DEPENDFILE}: _EXTRADEPEND

--------------070009000100030605080704--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F202FB7.8010609>