aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-15 13:27:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-15 13:27:51 +0200
commita0760272b634c6e468d4772e80aab27d4b05b787 (patch)
tree226a0388929743258d14cd5b99831941325ead2a /build2
parentb611e797ad9db9794f4d151f454fa731d12b0bd3 (diff)
Instrument cc:link_rule with backwards mtime detection/diagnostics
Diffstat (limited to 'build2')
-rw-r--r--build2/cc/link-rule.cxx20
1 files changed, 20 insertions, 0 deletions
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.