[Top][All Lists]

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

Re: Inconsistent behaviour when building in parallel

From: Paul Smith
Subject: Re: Inconsistent behaviour when building in parallel
Date: Sun, 21 Jan 2007 17:22:15 -0500

On Sat, 2007-01-20 at 22:22 +0100, Dirk Heinrichs wrote:

> > In the parallel case, make does exactly the same thing EXCEPT that
> > instead of waiting for the first command to complete it immediately
> > checks the second target and, since the first command is not done yet
> > and hasn't updated it, make sees that it's still out of date so it runs
> > that rule again to update it.
> So the left hand doesn't know what the right hand does? I consider this a bad 
> thing.

I do too, and so does make: that's why you shouldn't do it.  After all,
make cannot know what the commands you give it will REALLY do, it can
only assume that they will do what you've told it they will do: namely,
update the target file.

However, in your makefile your commands don't just update the target
file that you told make they would, they also update some OTHER target
files that you didn't tell make about.  So, make doesn't expect the
commands to update those target files.

In this case, the two hands you refer to are your commands that you
wrote and added to your makefile, so you can hardly blame make for what
they may be doing behind each others' backs.

> > In the parallel case you can't tell exactly what will happen: it depends
> > on your system; how busy it is, what order the various jobs are
> > scheduled by the OS, how long the command takes to execute, etc.  It
> > could work perfectly, or it could be run twice, or more times (if there
> > are more than two targets).
> That's even worse.

Perhaps, but as Eli points out this is a feature of the operating system
and is completely out of make's control.  When you run multiple commands
in parallel on a multitasking system, you cannot control the order in
which they are executed.  That's the entire point: if they always ran in
a fixed order then they wouldn't be parallelized, would they?

As Eli says, if you want serialized command execution it's trivial to
get from make: just don't enable parallel builds.

 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]