Subject: race in bsd.kinc.mk
To: None <tech-toolchain@netbsd.org>
From: Chuck Silvers <chuq@chuq.com>
List: tech-toolchain
Date: 10/11/2003 17:43:35
--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

hi,

there's a parallel-build race in bsd.kinc.mk, we may try to install a file
into the DESTDIR before we create the directory it goes in:

--- includes-sys ---
--- includes-include ---
--- /build/destdir/usr/include/sparc64 ---
creating /build/destdir/usr/include/sparc64
--- includes-usr.bin ---
includes ===> usr.bin/cmp
--- includes-sys ---
--- /build/destdir/usr/include/sparc64/ansi.h ---
STRIP=/build/tooldir/bin/sparc64--netbsd-strip /build/tooldir/bin/nbinstall -U -M /build/destdir/METALOG -D /build/destdir -N /build/src/etc -p -r -c -o root -g wheel  -m 444  ansi.h /build/destdir/usr/include/sparc64/ansi.h
nbinstall: /build/destdir/usr/include/sparc64: mkstemp: No such file or directory
--- /build/destdir/usr/include/sparc64/aout_machdep.h ---
--- includes-usr.bin ---
--- includes-col ---



the attached patch seems to fix it, does anyone see anything wrong with it?


it seems to me that it'd be way easier to find all the races if we had
a way to do a non-parallel make with the parallelizable targets in reverse
order from how they are listed in the Makefile.  that should catch the
vast majority of races.  I imagine there's some way to do this in the .mk
files, but I'm not fluent enough in make to know how.  anyone know how to
do this?

-Chuck

--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.kinc"

Index: share/mk/bsd.kinc.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.kinc.mk,v
retrieving revision 1.29
diff -u -r1.29 bsd.kinc.mk
--- share/mk/bsd.kinc.mk	3 Aug 2003 09:23:16 -0000	1.29
+++ share/mk/bsd.kinc.mk	12 Oct 2003 00:33:00 -0000
@@ -21,15 +21,14 @@
 
 ##### Basic targets
 .PHONY:		incinstall
-includes:	${INCS} incinstall
+.PHONY:		${DESTDIR}${INCSDIR}
+.PRECIOUS:	${DESTDIR}${INCSDIR}
+includes:	${DESTDIR}${INCSDIR} .WAIT ${INCS} incinstall
 
 ##### Install rules
 incinstall::	# ensure existence
 
 # make sure the directory is OK, and install includes.
-incinstall::	${DESTDIR}${INCSDIR}
-.PRECIOUS:	${DESTDIR}${INCSDIR}
-.PHONY:		${DESTDIR}${INCSDIR}
 
 ${DESTDIR}${INCSDIR}:
 	@if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \

--7JfCtLOvnd9MIVvH--