From a0760272b634c6e468d4772e80aab27d4b05b787 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Nov 2018 13:27:51 +0200 Subject: Instrument cc:link_rule with backwards mtime detection/diagnostics --- build2/cc/link-rule.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'build2') diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index a9ee0e9..203c290 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -2071,6 +2071,8 @@ namespace build2 if (dd.writing () || dd.mtime () > mt) scratch = update = true; + timestamp dd_tt (system_clock::now ()); + bool dd_rd (dd.reading ()); dd.close (); // If nothing changed, then we are done. @@ -2539,6 +2541,24 @@ namespace build2 rm.cancel (); + { + timestamp tp_tt (system_clock::now ()); + + path dd (tp + ".d"); + + timestamp dd_mt (file_mtime (dd)); + timestamp tp_mt (file_mtime (tp)); + + if (dd_mt > tp_mt) + { + fail << "backwards modification times:\n" + << dd.string () << " " << dd_mt << " (" << dd_rd << ")\n" + << tp.string () << " " << tp_mt << '\n' + << dd_tt << '\n' + << tp_tt; + } + } + // Should we go to the filesystem and get the new mtime? We know the // file has been modified, so instead just use the current clock time. // It has the advantage of having the subseconds precision. -- cgit v1.1