Subject: bug#1705: 23.0.60; parallel build failure: `mh-e' was not provided

From: Eli Zaretskii <[email-masked]>
Date: Sat, 27 Dec 2008 14:19:44 +0200

> From: Markus Triska <[email-masked]>
> Date: Thu, 25 Dec 2008 23:27:56 +0100 (CET)
> Cc: 
> 
> 
> A parallel compilation (-j 2) with today's CVS version aborted with:
> 
>    In toplevel form:
>    mh-e/mh-folder.el:34:1:Error: Required feature `mh-e' was not provided
>    Wrote /Users/mt/emacs/lisp/mh-e/mh-e.elc
>    Compiling /Users/mt/emacs/lisp/mh-e/mh-funcs.el
>    make[1]: *** [/Users/mt/emacs/lisp/mh-e/mh-folder.elc] Error 1
>    make[1]: *** Waiting for unfinished jobs....
>    make[1]: *** Waiting for unfinished jobs....
>    No MH variant found on the system
>    Wrote /Users/mt/emacs/lisp/mh-e/mh-funcs.elc
>    make: *** [lisp] Error 2

This is because we don't tell Make all the truth about the
dependencies between Lisp files, so it by default assumes that
mh-funcs.elc and mh-e.elc are independent, and compiles them in two
different jobs that run in parallel.  But the truth is that
mh-funcs.el says this:

   (require 'mh-e)

which causes Emacs to look for mh-e.elc when it compiles mh-funcs.el.
So there's a race condition here between the 2 jobs that Make runs in
parallel under "-j 2": one job compiles mh-e.el and writes mh-e.elc,
while the other job, which compiles mh-funcs.el, reads from mh-e.elc.
In this case, the reading job evidently accessed mh-e.elc after it was
already created, but before it was written in its fullness (as you see
above, the "Wrote /Users/mt/emacs/lisp/mh-e/mh-e.elc" message is
printed _after_ the error message).  So the "provide" form was not yet
in mh-e.elc when it was read, and Emacs barfed.

In general, we lack such dependencies all over lisp/Makefile.in, so I
submit that "make -j N" works for us by sheer luck: I'm guessing that
this is due to small values of N and the fact that $(ELCFILES) causes
Make to compile files in alphabetic order, combined with very few
dependencies between Lisp files whose names come close to one another
in that order.  But given a large enough value of N (and a
correspondingly large number of processors on the system), we should
see such failures all the time.

I added to lisp/Makefile.in a series of dependencies that should fix
the case of MH-E compilation.  Please see if this fixes the problem
for you.  If you have more than 2 processors, it would make sense to
try "make -j N" with values of N larger than 2, to increase the
probability of such a clash.