bug-make
[Top][All Lists]
Advanced

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

Re: say which of .PRECIOUS: %.o *.o file.o will actually work


From: Edward Welbourne
Subject: Re: say which of .PRECIOUS: %.o *.o file.o will actually work
Date: Fri, 11 Oct 2024 09:45:12 +0000

Paul Smith (10 October 2024 17:56) wrote:
> .PRECIOUS is dangerous and should almost never be needed or used.  Its
> goal is to prevent make from deleting files automatically when a
> recipe fails (for any reason).  There are very few, very rare
> situations where this is what you want, because it means that if (for
> example) the user uses ^C to kill a build and the recipe leaves a
> half-constructed target file behind your build will start to fail
> until you go delete it by hand.

This danger can be avoided by having a recipe (or the command it runs)
generate the new file under an alternative name and finish up, on
success, by doing a rename to replace the old version.  This is not,
however, what many commands driven by makefiles commonly do, though it
can sometimes be useful in conjunction with a "check if they're
different before replacing" step to avoid changing the generated file's
timestamp if it's unchanged.  (That does lead to the same rule being
exercised on later builds, as the file remains out of date wrt its
sources, but may be worth doing when vast amounts of everything else get
rebuilt every time the target actually does change; verifying it hasn't
changed on each build is cheaper than rebuilding the universe every
time.  This can arise, for example, when parts of your build
configuration are built by a separate tool.)

> I have a hard time even imagining a good reason to use it.

That, I grant, remains true even with the above complications,

        Eddy.



reply via email to

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