summaryrefslogtreecommitdiffstats
path: root/src/graph.cc
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-07 14:56:25 (GMT)
committerBrad King <brad.king@kitware.com>2017-09-08 13:07:52 (GMT)
commitc0dde0ff7911780152dbe86d5782ebdecfeb37f2 (patch)
treefa0c474dbf0d9254e8346fdc4f9b2c79c5bbc63e /src/graph.cc
parente679202a14d9ca08ccd0f471f2bcbf6388ddb3de (diff)
downloadNinja-c0dde0ff7911780152dbe86d5782ebdecfeb37f2.zip
Ninja-c0dde0ff7911780152dbe86d5782ebdecfeb37f2.tar.gz
Ninja-c0dde0ff7911780152dbe86d5782ebdecfeb37f2.tar.bz2
Restore tolerance of self-referencing phony build statements
Since commit v1.8.0^2~3^2~1 (Teach RecomputeDirty to detect cycles in the build graph, 2015-11-13) we correctly reject self-referencing phony build statements like build a: phony a as cycles. Unfortunately this breaks support for CMake 2.8.12.x and 3.0.x because those versions incorrectly produce edges of this form (that we used to tolerate). In order to preserve compatibility with those CMake versions we need to restore tolerance of these edges. Add a special case to the manifest parser to filter out self-referencing inputs of phony edges of the form produced by those CMake versions. Warn by default, but add a `-w phonycycle={err,warn}` option to make it an error. Fixes: #1322
Diffstat (limited to 'src/graph.cc')
-rw-r--r--src/graph.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/graph.cc b/src/graph.cc
index 7dd9491..ce4ea77 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -170,6 +170,13 @@ bool DependencyScan::VerifyDAG(Node* node, vector<Node*>* stack, string* err) {
err->append(" -> ");
}
err->append((*start)->path());
+
+ if ((start + 1) == stack->end() && edge->maybe_phonycycle_diagnostic()) {
+ // The manifest parser would have filtered out the self-referencing
+ // input if it were not configured to allow the error.
+ err->append(" [-w phonycycle=err]");
+ }
+
return false;
}
@@ -410,6 +417,14 @@ bool Edge::use_console() const {
return pool() == &State::kConsolePool;
}
+bool Edge::maybe_phonycycle_diagnostic() const {
+ // CMake 2.8.12.x and 3.0.x produced self-referencing phony rules
+ // of the form "build a: phony ... a ...". Restrict our
+ // "phonycycle" diagnostic option to the form it used.
+ return is_phony() && outputs_.size() == 1 && implicit_outs_ == 0 &&
+ implicit_deps_ == 0;
+}
+
// static
string Node::PathDecanonicalized(const string& path, uint64_t slash_bits) {
string result = path;