[Top][All Lists]

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

Idea: Automatically detect erroneous multi-targets

From: David A. Wheeler
Subject: Idea: Automatically detect erroneous multi-targets
Date: Tue, 11 Jun 2019 14:23:57 -0400 (EDT)

Idea: Automatically detect erroneous multi-targets


In many cases people write (though ignorance or accident) rules like this:
BB CC: prerequisites
when they intended to say
"both BB and CC are simultaneously generated by command".
Of course, what that really means is that the command could be
run multiple times (once for each target), and that can mess things up.

The new "&:" provides a clean way to notate this (instead of ":"),
and *portable* way to express this is the uglier:

BB CC: some_marker ;
some_marker: prerequisites
<TAB>touch $@

The problem is that although it's *possible* to express
the intended relationship, it's really easy to express the *wrong* relationship.

Proposed solution:

Make should try to automatically detect & warn about this common mistake.
Here's how.

When multiple targets are listed in a traditional rule (":" not "&:"),
after running a rule in non-parallel mode, check to see if any of the
other targets were modified (by presence, length, and modification time).
If they were, generate a warning like this:

Makefile:141: *** Warning: Use &: (not :) or an intermediary target when 
modifying multiple targets: (target names)

I don't know of any reason you'd want to silence warnings.
If you did, I think that'd be a separate change (to be proposed separately).

Sorry for the continuing blizzard of ideas :-).
Hopefully some are useful...!

--- David A. Wheeler

reply via email to

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