From ac5ef35b5fa8b938ed427df4b0ad44e5b6b52cff Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 19 Nov 2018 14:58:20 +0200 Subject: Finalize workaround for backwards modification time issue --- build2/cc/compile-rule.cxx | 10 +++++----- build2/cc/link-rule.cxx | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'build2/cc') 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. -- cgit v1.1