On Fri, Feb 28, 2025 at 13:07:04 -0500, Paul Smith wrote:
> On Fri, 2025-02-28 at 18:05 +0100, Ben Boeckel via Gcc wrote:
> > Note that one thing that is missing is ninja's `restat = 1` feature.
> > This "restats" the output for the associated rule (probably spelled
> > `.RESTAT: output` in Make) and skips running dependent rules if the
> > output has not updated the mtime of the output(s) before the rule
> > (recipe) was executed. This can be used for modules to not have to
> > recompile sources that import the output modules it if they didn't
> > change
> 
> I've seen this statement a few times and I've read the description of
> restat in the Ninja docs and also the above, and I guess I'm just too
> dumb to understand it.
> 
> Can someone explain with an example?
> 
> In POSIX make, including GNU Make, if a command doesn't modify the
> modification time of the target then that target is not considered
> updated, and other targets which list it as a prerequisite are not
> invoked:

Hmm. My understanding was that if a recipe is run, its outputs are
assumed to have been updated. I forget where I saw that, but it sticks
in my mind for some reason. Experimenting with GNU Make indeed does
exhibit `restat = 1` behavior out-of-the-box. That's good to know :) .
I'll update my priors. Thanks for the check. Here's my test case I was
working with with better names:

```make
restat_output: restat_input
        cp -v $< $@
restat_input: source
        diff -q $< $@ || cp -v $< $@
```

--Ben

Reply via email to