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 14:02:06 -0400
User-agent: Evolution 3.44.1 (by Flathub.org))

On Sat, 2022-05-21 at 19:06 +0200, Alejandro Colomar wrote:
> By "once all children are complete" you are implying the "existence"
> of the children (which make(1) doesn't really check, but one can
> think of it as if it did).

Perhaps that's the confusion.  Make doesn't care about files at all per
se: it treats the filesystem as a key/value store where the key is the
pathname and the value is the mod time.  It will look up each target in
that store (filesystem) and if it doesn't exist it gets a special
"oldest" timestamp so that the recipe is run.  After the recipe is run
make gives the node a special "newest" timestamp so targets that list
it as a prerequisite are out of date.  It's not an error (to make) if
the key (pathname) still doesn't exist after the recipe runs.

Make really only cares about its internal graph.  The filesystem is
just a place to keep target state in between invocations of make (and
of course, a way for other tools to let make know that something
changed), since make doesn't have its own database.

Having make complain for any non-phony target that didn't actually
create its target would violate POSIX, and probably cause hundreds of
thousands of makefiles out there to throw complaints where people
forgot or didn't want to bother with using .PHONY (not all makefiles
were written for GNU make, and .PHONY is a GNU make feature).



reply via email to

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