aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-19 14:58:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-19 14:58:20 +0200
commitac5ef35b5fa8b938ed427df4b0ad44e5b6b52cff (patch)
treefa1544e9ba088d4e054a095eec6a196502361d4e /build2/cc
parent5136a6b723e2eeb27718747f1bfd822d0e790b86 (diff)
Finalize workaround for backwards modification time issue
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/compile-rule.cxx10
-rw-r--r--build2/cc/link-rule.cxx25
2 files changed, 18 insertions, 17 deletions
diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx
index 634a586..e361e9d 100644
--- a/build2/cc/compile-rule.cxx
+++ b/build2/cc/compile-rule.cxx
@@ -751,8 +751,7 @@ namespace build2
// Note: the leading '@' is reserved for the module map prefix (see
// extract_modules()) and no other line must start with it.
//
- md.dd = tp + ".d";
- depdb dd (md.dd);
+ depdb dd (tp + ".d");
// First should come the rule name/version.
//
@@ -824,7 +823,7 @@ namespace build2
// the target (interrupted update), then do unconditional update.
//
timestamp mt;
- bool u (dd.writing () || dd.mtime () > (mt = file_mtime (tp)));
+ bool u (dd.writing () || dd.mtime > (mt = file_mtime (tp)));
if (u)
mt = timestamp_nonexistent; // Treat as if it doesn't exist.
@@ -996,9 +995,10 @@ namespace build2
// we will keep re-validating the cached data over and over again.
//
if (u && dd.reading ())
- dd.touch ();
+ dd.touch = true;
dd.close ();
+ md.dd = move (dd.path);
// If the preprocessed output is suitable for compilation, then pass
// it along.
@@ -1036,7 +1036,7 @@ namespace build2
// store the first in the target file (so we do touch it) and the
// second in depdb (which is never newer that the target).
//
- md.mt = u ? timestamp_nonexistent : dd.mtime ();
+ md.mt = u ? timestamp_nonexistent : dd.mtime;
}
switch (a)
diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx
index 90d290d..77619d1 100644
--- a/build2/cc/link-rule.cxx
+++ b/build2/cc/link-rule.cxx
@@ -2068,11 +2068,14 @@ namespace build2
// this situation in the "from scratch" flag.
//
bool scratch (false);
- if (dd.writing () || dd.mtime () > mt)
+ if (dd.writing () || dd.mtime > mt)
scratch = update = true;
+#define MTIME_SANITY_CHECK
+#ifdef MTIME_SANITY_CHECK
timestamp dd_tt (system_clock::now ());
- bool dd_rd (dd.reading ());
+#endif
+
dd.close ();
// If nothing changed, then we are done.
@@ -2080,9 +2083,6 @@ namespace build2
if (!update)
return ts;
- path ddp (tp + ".d");
- timestamp dd_mt (file_mtime (ddp));
-
// Ok, so we are updating. Finish building the command line.
//
string in, out, out1, out2, out3; // Storage.
@@ -2544,19 +2544,20 @@ namespace build2
rm.cancel ();
+#ifdef MTIME_SANITY_CHECK
{
- timestamp tp_tt (system_clock::now ());
timestamp tp_mt (file_mtime (tp));
+ timestamp dd_mt (file_mtime (dd.path));
+ timestamp tp_tt (system_clock::now ());
if (dd_mt > tp_mt)
- {
fail << "backwards modification times:\n"
- << ddp.string () << " " << dd_mt << " (" << dd_rd << ")\n"
- << tp.string () << " " << tp_mt << '\n'
- << dd_tt << '\n'
- << tp_tt;
- }
+ << dd_tt << " window start\n"
+ << dd_mt << " " << dd.path.string () << '\n'
+ << tp_mt << " " << tp.string () << '\n'
+ << tp_tt << " window end";
}
+#endif
// 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.