Instead of relying on modification-time comparisons between dependency and target output, use hashes of the relevant "ingredients" of building a target (cmdline, arguments, meta-data about input files etc.).
I’m a little confused by some of this (mtime vs manifest) because Ninja does rebuild things if things like the command line changes, doesn’t it? Or have I misunderstood how this tool works forever…