help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Prerequisite ordering - make 3.81


From: Paul Smith
Subject: RE: Prerequisite ordering - make 3.81
Date: Sun, 28 Jan 2007 18:02:12 -0500

On Tue, 2007-01-23 at 12:11 +0000, Dave Korn wrote:
> On 22 January 2007 15:09, Daniel Thom wrote:

> > As long as the 'target:' line with the "This operation is important. . ."
> > statement comes *BEFORE* 'target: two' the behavior is as shown above.  If
> > it is below 'target: two' both versions of make behave the same.
> > 
> > Is this an expected difference between the two versions (I'm guessing it
> > is)? I did look at the info pages and google around, but I didn't see an
> > answer for this exact (and very simple) scenario.  I'm sure I can work
> > around this difference, though I need to support multiple versions of make
> > and would prefer not to kludge this too badly if this is a bug rather than
> > expected behavior (this is a much simplified example).
> 
> Make builds a tree (directed acyclic graph actually) of dependencies and
> walks it building prerequisites.  There has /never/ been /any/ guarantee about
> the order in which it walks the tree, and assuming that it will or won't visit
> nodes in any given order is an incorrect assumption.

Actually, that's not so.  Make does guarantee that prerequisites are
walked in the order they appear in the rule.

What's not as specifically defined is the order in which prerequisites
are walked when multiple rules are created for the same target.  In
order for automatic variables such as $< to work properly it's always
been the case that the prerequisites provided in the rule that contains
the command script are ordered first, and any other rules come
afterwards.

Offhand I'd say that after the prerequisites associated with the rule
are completed, make should continue with the rest of the prerequisites
in the order in which they were defined in the makefile.  If that used
to be the case and no longer is, I believe this is worthy of filing a
bug on Savannah.

> This is one of the commonest causes of bugs that only appear when you
> use the -j option for parallel make, because when you do that your
> previous assumptions about order of building targets can go right out
> the window.

Sort of.  What make does is still follow the same well-defined ordering,
but since multiple commands are started at the same time, and you don't
know when previous ones will finish, etc. you simply can no longer
guarantee that any given prerequisite will be finished building before
another starts, unless you explicitly declare to make that there's at
least an ordering relationship there.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]