Преглед изворни кода

Ninja: Fix non-determinism in generated target dependency order (#15968)

We represent target dependency sets as `set<cmTargetDepend>` which
orders by a `cmGeneratorTarget const*` pointer value.  Therefore the
order of dependencies encountered in AppendTargetDepends is not
predictable.  Sort them by content to make the result deterministic.
Brad King пре 9 година
родитељ
комит
46fa958362
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      Source/cmGlobalNinjaGenerator.cxx

+ 4 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -991,6 +991,7 @@ cmGlobalNinjaGenerator
     std::set<std::string> const& utils = target->GetUtilities();
     std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
   } else {
+    cmNinjaDeps outs;
     cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
     for (cmTargetDependSet::const_iterator i = targetDeps.begin();
          i != targetDeps.end(); ++i)
@@ -999,8 +1000,10 @@ cmGlobalNinjaGenerator
         {
         continue;
         }
-      this->AppendTargetOutputs(*i, outputs);
+      this->AppendTargetOutputs(*i, outs);
     }
+    std::sort(outs.begin(), outs.end());
+    outputs.insert(outputs.end(), outs.begin(), outs.end());
   }
 }