[Cmake-commits] CMake branch, next, updated. v3.1.0-rc1-502-g47374d6

Brad King brad.king at kitware.com
Mon Nov 10 13:59:50 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  47374d622e9f0543875c4dfca4174ed60a19323b (commit)
       via  bf2b06bad6dd328e707ef15f48d576a5a6cd811f (commit)
       via  a2ecf91b1c5226b9898757d3689a616f97a7ac6c (commit)
      from  dfddf17df79aa61b1a305d0480ab8c1b7f95a5c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47374d622e9f0543875c4dfca4174ed60a19323b
commit 47374d622e9f0543875c4dfca4174ed60a19323b
Merge: dfddf17 bf2b06b
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Nov 10 13:59:49 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Nov 10 13:59:49 2014 -0500

    Merge topic 'fix_link-line-dedup_regression' into next
    
    bf2b06ba Test linking to a shared lib needed only through a static lib
    a2ecf91b Fix link line order when shared libraries are de-duplicated


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bf2b06bad6dd328e707ef15f48d576a5a6cd811f
commit bf2b06bad6dd328e707ef15f48d576a5a6cd811f
Author:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Sun Nov 9 17:51:18 2014 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Nov 10 13:58:16 2014 -0500

    Test linking to a shared lib needed only through a static lib

diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt
index ef42048..ebc2d10 100644
--- a/Tests/Dependency/CMakeLists.txt
+++ b/Tests/Dependency/CMakeLists.txt
@@ -51,3 +51,4 @@ add_subdirectory(Case1)
 add_subdirectory(Case2)
 add_subdirectory(Case3)
 add_subdirectory(Case4)
+add_subdirectory(Case5)
diff --git a/Tests/Dependency/Case5/CMakeLists.txt b/Tests/Dependency/Case5/CMakeLists.txt
new file mode 100644
index 0000000..f04ab83
--- /dev/null
+++ b/Tests/Dependency/Case5/CMakeLists.txt
@@ -0,0 +1,12 @@
+project(CASE5 C)
+
+include_directories(${CASE5_SOURCE_DIR})
+
+add_library(case5Foo SHARED foo.c foo.h)
+
+add_library(case5Bar STATIC bar.c bar.h)
+target_link_libraries(case5Bar case5Foo)
+
+add_executable(case5 main.c)
+target_link_libraries(case5 case5Foo)
+target_link_libraries(case5 case5Bar)
diff --git a/Tests/Dependency/Case5/bar.c b/Tests/Dependency/Case5/bar.c
new file mode 100644
index 0000000..2a70fde
--- /dev/null
+++ b/Tests/Dependency/Case5/bar.c
@@ -0,0 +1,10 @@
+#include "bar.h"
+
+#include <foo.h>
+#include <stdio.h>
+
+void bar()
+{
+    foo();
+    printf("bar()\n");
+}
diff --git a/Tests/Dependency/Case5/bar.h b/Tests/Dependency/Case5/bar.h
new file mode 100644
index 0000000..aee2dc6
--- /dev/null
+++ b/Tests/Dependency/Case5/bar.h
@@ -0,0 +1 @@
+void bar();
diff --git a/Tests/Dependency/Case5/foo.c b/Tests/Dependency/Case5/foo.c
new file mode 100644
index 0000000..c0153bd
--- /dev/null
+++ b/Tests/Dependency/Case5/foo.c
@@ -0,0 +1,8 @@
+#include "foo.h"
+
+#include <stdio.h>
+
+void foo()
+{
+    printf("foo()\n");
+}
diff --git a/Tests/Dependency/Case5/foo.h b/Tests/Dependency/Case5/foo.h
new file mode 100644
index 0000000..c8620b6
--- /dev/null
+++ b/Tests/Dependency/Case5/foo.h
@@ -0,0 +1 @@
+void foo();
diff --git a/Tests/Dependency/Case5/main.c b/Tests/Dependency/Case5/main.c
new file mode 100644
index 0000000..8213496
--- /dev/null
+++ b/Tests/Dependency/Case5/main.c
@@ -0,0 +1,7 @@
+#include <bar.h>
+
+int main(int argc, char *argv[])
+{
+    bar();
+    return 0;
+}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a2ecf91b1c5226b9898757d3689a616f97a7ac6c
commit a2ecf91b1c5226b9898757d3689a616f97a7ac6c
Author:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Sun Nov 9 17:35:20 2014 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Nov 10 13:58:15 2014 -0500

    Fix link line order when shared libraries are de-duplicated
    
    Since commit v3.1.0-rc1~227^2~1 (De-duplicate shared library targets in
    generated link lines, 2014-07-30) we de-duplicate shared library targets
    on the link line.  However, some toolchains will fail linking if an
    executable is linking to a shared library that is not used directly and
    a static library that depends on the shared one.  The linker may not
    keep the reference to the shared library the first time and then the
    symbols needed by the static library may not be found.
    
    Fix this by reversing the direction of the for loop that removes the
    duplicate shared libraries, in order to ensure that the last occurrence
    of the library is left instead of the first one.
    
    Co-Author: Brad King <brad.king at kitware.com>

diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index b13a125..1fb8f30 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -263,21 +263,26 @@ cmComputeLinkDepends::Compute()
   this->OrderLinkEntires();
 
   // Compute the final set of link entries.
+  // Iterate in reverse order so we can keep only the last occurrence
+  // of a shared library.
   std::set<int> emmitted;
-  for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin();
-      li != this->FinalLinkOrder.end(); ++li)
+  for(std::vector<int>::const_reverse_iterator
+        li = this->FinalLinkOrder.rbegin(),
+        le = this->FinalLinkOrder.rend();
+      li != le; ++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.
+    // Entries that we know the linker will re-use 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);
       }
     }
+  // Reverse the resulting order since we iterated in reverse.
+  std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end());
 
   // Display the final set.
   if(this->DebugMode)

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list