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:

  $ cat Makefile
  MKTWO = touch
  one: two ; touch $@
  two: three ; $(MKTWO) $@

When we change "three" and then allow the MKTWO recipe to update "two"
then "one" is out-of-date and rebuilt:

  ~$ touch three; make
  touch two
  touch one

  ~$ touch three; make
  touch two
  touch one

When we change "three" then cause the MKTWO recipe to NOT update "two",
then "one" is not out-of-date and not rebuilt:

  ~$ touch three; make -f /tmp/x3.mk MKTWO=echo
  echo two
  two


Can someone explain how the Ninja "restat" feature differs from this?

Reply via email to