bug-make
[Top][All Lists]
Advanced

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

Re: Potential Bug: `.PHONY` targets and order-only prerequisites


From: Paul Smith
Subject: Re: Potential Bug: `.PHONY` targets and order-only prerequisites
Date: Sat, 21 May 2022 12:24:34 -0400
User-agent: Evolution 3.44.1 (by Flathub.org))

On Wed, 2022-05-18 at 14:36 -0700, Jacob Kopczynski wrote:
> The thing that the docs refer to as "impose order" is not a single
> thing, but two. I would characterize a normal prerequisite as doing
> three things rather than two:
> - update-marking: cause a target to be marked out of date if the
> prereq is marked out of date
> - require-existence: require the prereq to be built successfully at
> least once before the target is built
> - imposed-order: require the prereq to be built before the target, if
> both are being built

I guess I've just been using make for too long because I don't
understand the distinction you're trying to make between the last two.
There's no difference here, and the extra comment at the end "if both
are being built" is not meaningful (or anyway I don't understand what
it means).

Let's review how make works: it reads the makefile(s) and builds a
directed acyclic graph where every target is a node and every
prerequisite relationship is an edge between two nodes.

Then starting with each node representing a goal target (either the
first target in the makefile, or the target(s) given on the command
line) make performs a depth-first walk of the graph starting at that
node.  "Walking the graph" consists of processing each child node
recursively, in order, and once all children are complete make compares
the timestamp of each (not order-only) child node to the timestamp of
the current node.  If the current node is out of date, then it is
updated (by running its recipe), else we do nothing.  Then this node is
complete and we return to the processing of the parent node, or if
we're the goal target then we're done.

I don't see any way that you can talk about "require-existence"
separately from "imposed-order", and the attempt to do so is (it seems
to me) just creating confusion.

> For .PHONY targets, require-existence always mandates update-marking,
> which is why the overlap between those two cases is particularly
> confusing - a phony target which drops only update-marking is a
> contradiction in terms, so the natural assumption to make is that the
> effect of "order-only" prereqs is not that, and is instead something
> non-paradoxical.

Order-only prerequisites weren't created because people wanted to use
them with .PHONY targets.  They were created for use with non-phony
targets.

You can add them into phony targets, but they make no difference there
as we described.

Maybe what you're saying is that make should throw an error or warning
if you try to add an order-only prerequisite to a phony target, telling
you that it will have no effect on your makefile?

Perhaps.  I'm generally not inclined to do that sort of thing but maybe
it would be helpful.  Many people have asked for an equivalent to a GCC
-Wall flag for GNU make that gives warnings about things that are
probably not doing what you expected.



reply via email to

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