help-make
[Top][All Lists]
Advanced

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

Re: Race condition with parallel recursive make


From: Paul Smith
Subject: Re: Race condition with parallel recursive make
Date: Wed, 09 Mar 2011 07:56:14 -0500

On Wed, 2011-03-09 at 11:54 +0100, Christian Rishøj Jensen wrote:
> I have a project with several sub-directories, each having some
> targets which share a common dependency. The sub-directories are
> handled by spawning sub-makes (using the special $(MAKE) variable).
> 
> Now, when running make with e.g. -j4 I see that several of the
> sub-makes are attempting to build the common dependency at the same
> time. This is obviously not desirable. 
> 
> I was under the impression that the jobserver would prevent such
> situations, by keeping track of what each sub-make is doing. I might
> be mistaken. Can someone cast some light on this?

No, that's not what the jobserver does.  All it does is ensure that, if
you specify -jN, there are never more than "N" jobs running at the same
time across all the instances of make (spawned from the same top-level
instance).  It doesn't check to see what targets those jobs are
building.

> Is there a method for avoiding this sort of race condition?

You must have the target built by only one makefile, and the other
makefiles should merely depend on it.  Whenever you have more than one
makefile that contains rules to build the same target, you have a
problem.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "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]