aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/compile-rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-04-10 14:16:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-04-10 15:16:32 +0200
commit9bd1a1619e282c585b3f202d84790f8811d1e4d6 (patch)
tree50d7660f772c123b4f24d06119821215d7497718 /build2/cc/compile-rule.cxx
parent47ee9b8274cba0014afe59019d76613da8bb45d6 (diff)
Always use cached mtime if available
Besides other things, this is required for "logical clean" in the try-run mode to work properly: $ b -vn clean update
Diffstat (limited to 'build2/cc/compile-rule.cxx')
-rw-r--r--build2/cc/compile-rule.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx
index 3050a37..92ba32d 100644
--- a/build2/cc/compile-rule.cxx
+++ b/build2/cc/compile-rule.cxx
@@ -823,8 +823,22 @@ namespace build2
// compiler, options, or source file) or if the depdb is newer than
// the target (interrupted update), then do unconditional update.
//
+ // Note that load_mtime() can only be used in the execute phase so we
+ // have to check for a cached value manually.
+ //
+ bool u;
timestamp mt;
- bool u (dd.writing () || dd.mtime > (mt = mtime (tp)));
+
+ if (dd.writing ())
+ u = true;
+ else
+ {
+ if ((mt = t.mtime ()) == timestamp_unknown)
+ t.mtime (mt = mtime (tp)); // Cache.
+
+ u = dd.mtime > mt;
+ }
+
if (u)
mt = timestamp_nonexistent; // Treat as if it doesn't exist.
@@ -1045,6 +1059,9 @@ 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).
//
+ // Perhaps when we start keeping the partially preprocessed this will
+ // fall away? Yes, please.
+ //
md.mt = u ? timestamp_nonexistent : dd.mtime;
}
@@ -4319,10 +4336,11 @@ namespace build2
if (md.touch)
{
touch (tp, false, 2);
+ t.mtime (system_clock::now ());
skip_count.fetch_add (1, memory_order_relaxed);
}
+ // Note: else mtime should be cached.
- t.mtime (md.mt);
return *pr.first;
}