Buildworld /rescue failures in 5.1

Tim Kientzle kientzle at acm.org
Thu Jul 24 12:12:54 PDT 2003


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
-------------- next part --------------
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


More information about the freebsd-current mailing list