summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2017-04-17 20:24:44 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2017-04-21 12:57:40 (GMT)
commitadf60b28384025d5b83c2df5a66f2190753e2695 (patch)
treec07e71eca348da7d33108042e6a897efba77166b /Source/cmNinjaTargetGenerator.cxx
parent01c5bb9551ff0322f2cb4d5439a2ab9a94c87815 (diff)
downloadCMake-adf60b28384025d5b83c2df5a66f2190753e2695.zip
CMake-adf60b28384025d5b83c2df5a66f2190753e2695.tar.gz
CMake-adf60b28384025d5b83c2df5a66f2190753e2695.tar.bz2
ninja: break unnecessary target dependencies
Previously, given two libraries, X and Y where X depends on Y, all object compilations of X would require the Y library to have been linked before being compiled. This is not necessary and can instead be loosened such that object compilations of X only depend on the order-only dependencies of Y to be completed. This is to ensure that generated sources, headers, custom commands, etc. are completed before X starts to compile its objects. This should help build performance in projects with many libraries which cause a deep library dependency chain. Previously, a library at the bottom would not start compilation until after all other libraries completed, but now only its link step needs to wait and its compilation jobs can be run in parallel with other tasks. Fixes: #15555
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx18
1 files changed, 8 insertions, 10 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index daad3fc..2c14a3e 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -715,8 +715,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
}
cmNinjaDeps orderOnlyDeps;
- this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget,
- orderOnlyDeps);
+ this->GetLocalGenerator()->AppendTargetDepends(
+ this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering);
// Add order-only dependencies on other files associated with the target.
orderOnlyDeps.insert(orderOnlyDeps.end(), this->ExtraFiles.begin(),
@@ -741,7 +741,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()),
orderOnlyDeps.end());
- if (!orderOnlyDeps.empty()) {
+ {
cmNinjaDeps orderOnlyTarget;
orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
this->GetGlobalGenerator()->WritePhonyBuild(
@@ -754,7 +754,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
for (std::vector<cmSourceFile const*>::const_iterator si =
objectSources.begin();
si != objectSources.end(); ++si) {
- this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty());
+ this->WriteObjectBuildStatement(*si);
}
if (!this->DDIFiles.empty()) {
@@ -779,8 +779,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
// our dependencies produces them. Fixing this will require
// refactoring the Ninja generator to generate targets in
// dependency order so that we can collect the needed information.
- this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget,
- ddOrderOnlyDeps);
+ this->GetLocalGenerator()->AppendTargetDepends(
+ this->GeneratorTarget, ddOrderOnlyDeps, DependOnTargetArtifact);
this->GetGlobalGenerator()->WriteBuild(
this->GetBuildFileStream(), ddComment, ddRule, ddOutputs, ddImplicitOuts,
@@ -791,7 +791,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
}
void cmNinjaTargetGenerator::WriteObjectBuildStatement(
- cmSourceFile const* source, bool writeOrderDependsTargetForTarget)
+ cmSourceFile const* source)
{
std::string const language = source->GetLanguage();
std::string const sourceFileName =
@@ -842,9 +842,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
cmNinjaDeps orderOnlyDeps;
- if (writeOrderDependsTargetForTarget) {
- orderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
- }
+ orderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
// If the source file is GENERATED and does not have a custom command
// (either attached to this source file or another one), assume that one of