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: Mike Shal
Subject: Re: Make with "-j8" sometime fail on a single-core machine
Date: Thu, 19 Nov 2009 08:24:24 -0500

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]