Subject: Re: tools/Makefile parallel make issue
To: Havard Eidnes <he@uninett.no>
From: Jachym Holecek <freza@dspfpga.com>
List: tech-toolchain
Date: 08/03/2006 01:51:50
Hello,

# Havard Eidnes 2006-08-02:
> > On Thu, Jul 06, 2006 at 05:25:02PM +0200, Lubomir Sedlacik wrote:
> > > the failure was caused by a "cleandir" running in parallel within the
> > > same directory "dependall" was just spawned (running configure at the
> > > moment), in tools/compat.
> > >
> > > the problem seems to lie in src/tools/Makefile:
> > >
> > >   realall realdepend: .MAKE
> > >   .if "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
> > >           @echo "*** WARNING: TOOLDIR has moved?"
> > >           @echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
> > >           @echo "***     !=  TOOLDIR '${TOOLDIR}'"
> > >           @echo "*** Cleaning mis-matched tools"
> > >           rm -f PREVIOUSTOOLDIR
> > >           (cd ${.CURDIR} && ${MAKE} cleandir)
> > >   .endif
> >
> > There is no way to get a single make command to execute commands that
> > delete files and commands that create the same ones.
>
> Is that really what's required here, though?
> 
> I would have thought that if the cleandir command completed before the
> rest was executed would have been sufficient, since most of the action
> here happens in subdirs, presumably in separate make processes?

This seems to indeed be the case -- realdepend & realall need
to be ordered WRT any relevant <bsd.subdir.mk>'s targets (which
are all .PHONY, so no actual conflicts can occur at this level).

Would the patch below be OK to commit? It's cleaner version
of the one posted prviously, put together with additional
input from Havard and tested by both of us with different
build.sh -jN levels.

	-- Jachym

Index: tools/Makefile
===================================================================
RCS file: /cvsroot/src/tools/Makefile,v
retrieving revision 1.104
diff -d -p -u -r1.104 Makefile
--- tools/Makefile	19 Jul 2006 09:54:47 -0000	1.104
+++ tools/Makefile	2 Aug 2006 23:16:17 -0000
@@ -176,6 +176,11 @@ install-${_prev}: dependall-${_prev}
 # .WAIT to achieve "closure" of the predecessor/successor relationships.
 .ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
 
+# Needed to prevent cleandir above from interfering with subdir makes:
+.ORDER: realdepend dependall-${d}
+.ORDER: realdepend depend-${d}
+.ORDER: realall all-${d}
+
 # make all/depend-${d} dependent on list of install targets
 depend-${d} all-${d} dependall-${d}: ${_deps}