bug-make
[Top][All Lists]
Advanced

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

RE: Make with "-j8" sometime fail on a single-core machine


From: He Yunlong-B20256
Subject: RE: Make with "-j8" sometime fail on a single-core machine
Date: Fri, 20 Nov 2009 10:03:19 +0800

Hi, Mike,

        Thanks very much for your patient clarification, is "one task"
only done by "one job"? 

        We are working with many opensource packages, it's really a
challenge to verify and update all makefiles, it seems such issues are
very general.

B.R.
Harry

-----Original Message-----
From: Mike Shal [mailto:address@hidden 
Sent: Thursday, November 19, 2009 9:24 PM
To: He Yunlong-B20256
Cc: address@hidden
Subject: Re: Make with "-j8" sometime fail on a single-core machine

On 11/19/09, He Yunlong-B20256 <address@hidden> wrote:
>
>
> Hi, Experts:
>
>     We met build errors with "[gdb] make -j8" for serveral times, but 
> it's ok to build with "-j1", we wonder whether this is some known 
> issue, and is it possible that something wrong in Makefile? We are
using gnu make 3.81.
>

Hello,

Make doesn't guarantee that the build is parallel-safe. Consider this
example:

$ cat Makefile
all: a b; echo "all done!"
a: ; echo hello > $@
b: ; cp a b

clean: ; rm -f a b

It works fine if you run with "-j1", since "a" will be built before "b".
With -j2, it is possible that both jobs for "a" and "b" will start at
the same time, so the command to create "a" may not have finished when
the command to create "b" tries to read it.

The problem of course is that the command for "b" is reading from the
file "a", which is created by another rule. These dependencies need to
always be specified in the Makefile, or otherwise be implicitly ordered
properly. The solution is to add that dependency to the Makefile, and
then it will always run correctly with -jX. However, it can be tricky to
find out what those missing dependencies are or where they need to go,
since you won't find out from make.

-Mike





reply via email to

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