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

Merge topic 'link-line-dedup'

ccec6df8 Help: Add notes for topic 'link-line-dedup'
9f7e27fc De-duplicate shared library targets in generated link lines
Brad King пре 11 година
родитељ
комит
628f02ba35
2 измењених фајлова са 18 додато и 2 уклоњено
  1. 5 0
      Help/release/dev/link-line-dedup.rst
  2. 13 2
      Source/cmComputeLinkDepends.cxx

+ 5 - 0
Help/release/dev/link-line-dedup.rst

@@ -0,0 +1,5 @@
+link-line-dedup
+---------------
+
+* When generating linker command-lines, CMake now avoids repeating
+  items corresponding to SHARED library targets.

+ 13 - 2
Source/cmComputeLinkDepends.cxx

@@ -166,7 +166,8 @@ guaranteed to be acyclic.
 
 
 The final list of items produced by this procedure consists of the
 The final list of items produced by this procedure consists of the
 original user link line followed by minimal additional items needed to
 original user link line followed by minimal additional items needed to
-satisfy dependencies.
+satisfy dependencies.  The final list is then filtered to de-duplicate
+items that we know the linker will re-use automatically (shared libs).
 
 
 */
 */
 
 
@@ -262,10 +263,20 @@ cmComputeLinkDepends::Compute()
   this->OrderLinkEntires();
   this->OrderLinkEntires();
 
 
   // Compute the final set of link entries.
   // Compute the final set of link entries.
+  std::set<int> emmitted;
   for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin();
   for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin();
       li != this->FinalLinkOrder.end(); ++li)
       li != this->FinalLinkOrder.end(); ++li)
     {
     {
-    this->FinalLinkEntries.push_back(this->EntryList[*li]);
+    int i = *li;
+    LinkEntry const& e = this->EntryList[i];
+    cmTarget const* t = e.Target;
+    // Entries that we know the linker will re-use for symbols
+    // needed by later entries do not need to be repeated.
+    bool uniquify = t && t->GetType() == cmTarget::SHARED_LIBRARY;
+    if(!uniquify || emmitted.insert(i).second)
+      {
+      this->FinalLinkEntries.push_back(e);
+      }
     }
     }
 
 
   // Display the final set.
   // Display the final set.