Pārlūkot izejas kodu

FASTBuild: fix multi-language PCHs

Fixes: #27371
Eduard Voronkin 1 mēnesi atpakaļ
vecāks
revīzija
878d154322
1 mainītis faili ar 5 papildinājumiem un 3 dzēšanām
  1. 5 3
      Source/cmFastbuildNormalTargetGenerator.cxx

+ 5 - 3
Source/cmFastbuildNormalTargetGenerator.cxx

@@ -1499,11 +1499,13 @@ void cmFastbuildNormalTargetGenerator::GenerateObjects(FastbuildTarget& target)
   objects.reserve(nodesPermutations.size());
   objects.reserve(nodesPermutations.size());
   for (auto& val : nodesPermutations) {
   for (auto& val : nodesPermutations) {
     auto& node = val.second;
     auto& node = val.second;
-    objects.emplace_back(std::move(node));
-    if (!objects.back().PCHInputFile.empty()) {
+    if (!node.PCHInputFile.empty()) {
       // Node that produces PCH should be the first one, since other nodes
       // Node that produces PCH should be the first one, since other nodes
       // might reuse this PCH.
       // might reuse this PCH.
-      std::swap(*objects.begin(), objects.back());
+      // Note: we might have several such nodes for different languages.
+      objects.insert(objects.begin(), std::move(node));
+    } else {
+      objects.emplace_back(std::move(node));
     }
     }
   }
   }
   if (useUnity) {
   if (useUnity) {