diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-11-10 22:35:39 (GMT) |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-02-08 00:07:14 (GMT) |
commit | abcd5f3d4d2ea3f58698fd3abcb7935ba8332f70 (patch) | |
tree | 4dd18e7916125ff37795f905b5ecd3229ae3d48c /src/ninja.cc | |
parent | 2993752dd617ada5218836dd6545fb06690e238b (diff) | |
download | Ninja-abcd5f3d4d2ea3f58698fd3abcb7935ba8332f70.zip Ninja-abcd5f3d4d2ea3f58698fd3abcb7935ba8332f70.tar.gz Ninja-abcd5f3d4d2ea3f58698fd3abcb7935ba8332f70.tar.bz2 |
Support restat when rebuilding manifest
As a fix for #874, we started reloading the entire manifest even if the
manifest was never rebuilt due to a restat rule. But this can be slow,
so call State::Reset instead, which also fixes the original crash.
Fixes #987
Diffstat (limited to 'src/ninja.cc')
-rw-r--r-- | src/ninja.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ninja.cc b/src/ninja.cc index 63ec3a8..54de7b9 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -247,10 +247,19 @@ bool NinjaMain::RebuildManifest(const char* input_file, string* err) { if (builder.AlreadyUpToDate()) return false; // Not an error, but we didn't rebuild. - // Even if the manifest was cleaned by a restat rule, claim that it was - // rebuilt. Not doing so can lead to crashes, see - // https://github.com/ninja-build/ninja/issues/874 - return builder.Build(err); + if (!builder.Build(err)) + return false; + + // The manifest was only rebuilt if it is now dirty (it may have been cleaned + // by a restat). + if (!node->dirty()) { + // Reset the state to prevent problems like + // https://github.com/ninja-build/ninja/issues/874 + state_.Reset(); + return false; + } + + return true; } Node* NinjaMain::CollectTarget(const char* cpath, string* err) { |