help-make
[Top][All Lists]
Advanced

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

Re: Performance loss when trying to use grouped targets


From: Dmitry Goncharov
Subject: Re: Performance loss when trying to use grouped targets
Date: Mon, 4 Mar 2024 21:01:14 -0500

On Mon, Mar 4, 2024 at 2:27 PM Stephen Touset via Users list for the
GNU implementation of make <help-make@gnu.org> wrote:

> sources := $(shell find src -mindepth 2 -type f)

$(wildcard ...) is faster than $(shell find ...).

...
> We jump through all these hoops for some important reasons. The build
> process often moves and/or removes files inside of the directories it’s
> working with. The above rules ensures that if the build is interrupted or
> fails a some point, if any files are missing for some component of the
> build, we’ll blow away that directory and start from scratch.

This desire to blow away that directory if build is interrupted or
fails is against the nature of make.
Make was created specifically to avoid blowing away a half completed build.


> It also
> ensures that each component is rebuilt if any of its individual sources
> changes.

You don't need to blow away a build director to ensure this.

...

> Is there a
> way to write a rule that expresses something closer to “each file in the
> build directory depends upon its corresponding file in the source
> directory” but still uses grouped targets?

A grouped targets rule like
a.x b.x &: a.q b.q; cp a.q b.q build/
tells make that a.x depends on a.q and b.q and b.x depends on a.q and
b.q. Which is not "each file depends on its corresponding file".

The above grouped rule is the same as
a.x: a.q b.q; cp a.q b.q build/
b.x: a.q b.q; cp a.q b.q build/

This rule tells make to compare mtimes of a.x against those of a.q and
b.q, rather than against mtime of a.q alone.


Do you want to copy all files when one source file changes?
Then
a.x: a.q; cp a.q b.q build/
b.x: b.q; cp a.q b.q build/

If you want to copy only the changed file alone.
Then
a.x: a.q; cp $< build/
b.x: b.q; cp $< build/


regards, Dmitry



reply via email to

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