[H-GEN] gnu make command-line target ordering problems?

Martin Pool martinp at mincom.com
Fri Oct 15 04:44:31 EDT 1999


[ Humbug *General* list - semi-serious discussions about Humbug and
Unix-related topics. ]

Ben Carlyle wrote:

> My problem is to do with the way it handles a combination of the
> -j option and multiple command-line targets, in which case it
> simply runs the command-line targets in parallel.
> I believe this is not the correct behaviour, but I thought I'd
> throw it to a wider audience before going too much further with
> it.

My understanding is:

  make -j TARGETS

first constructs a dependency graph, and then executes the graph seeking
the targets and using as much parallelism as is possible and permitted. 
In the example you give, there are no dependencies between the targets,
and so make sees no reason not to run them all in parallel.

By contrast, if you had

  b.b: a.a    # commands ommitted for brevity
  c.c: a.a

and did 

  make -j a.a b.b c.c

it would have to first make a.a by itself; once that was complete it can
make b.b and c.c in parallel.  The dependency graph tells make not to
try and build a.a twice in parallel, or to try and do b.b or c.c before
their precursor was available.  So it actually seems quite smart and
reasonable to me.

I'm not sure why you think this is not reasonable: 

  make a.a b.b c.c    # means "make a.a and b.b and c.c"

is really not the same as 

  make a.a && make b.b && make c.c  # "make a.a then b.b then c.c"

Although you will often get away with saying 

  make clean dep all install

it's at least bad form: depending on the makefile, make could well
decide that it doesn't _need_ to delete files because it's going to
rebuild them later.  However,

  make -j clean all 

> If you find that your make version has this problem, you can
> achieve a similar kernel compile (with error checking) using
> the following command:
> make dep && make clean && make bzImage && make modules && make
> modules_install

That's what I do.

While we're on the topic, the -k "keep trying" option is good: it uses
the graph to continue executing as many commands as possible even if
some errors are found.  This is good if eg you've broken several source
files and want to find all the errors in one go.  Make won't try to
build things who depend on the output of commands that failed, but will
try all other commands.

> So I guess what I'm really asking is this:
> Is this normal, or is it a problem with the new make version?

This is a feature ;-)  Patch your brain instead.

-- 
 /\\\  Mincom | Martin Pool          | martinp at mincom.com
// \\\        | Software Engineer    | Phone: +61 7 3303-3333
\\ ///        | Mincom Ltd.          | 
 \///         | Teneriffe, Brisbane  | Speaking for myself only

--
This is list (humbug) general handled by majordomo at lists.humbug.org.au .
Postings only from subscribed addresses of lists general or general-post.



More information about the General mailing list