[Lldb-commits] [PATCH] D16293: [cmake] Make dependencies of lldb libraries private

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 18 06:01:22 PST 2016


labath created this revision.
labath added a reviewer: zturner.
labath added a subscriber: lldb-commits.

The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files would be linked twice, once to liblldb and once again to lldb. I am not
sure why, but for some reason this only surfaced when doing a LLVM_LINK_LLVM_DYLIB=ON build,
where we ended having two copies of some symbols and different parts of code referring to
different copies.

Setting the dependencies as private required a fixup of the argdumper link command, as it was not
actually linking to liblldb (it was referring to symbols from the lldb_private namespace, which
are not exposed in liblldb), but rather to the individual component libraries (where these
symbols are still available). Since these symbols are now not added to the command line as
dependencies of liblldb, I needed to add them explicitly.

http://reviews.llvm.org/D16293

Files:
  cmake/modules/AddLLDB.cmake
  tools/argdumper/CMakeLists.txt

Index: tools/argdumper/CMakeLists.txt
===================================================================
--- tools/argdumper/CMakeLists.txt
+++ tools/argdumper/CMakeLists.txt
@@ -1,8 +1,16 @@
+include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+
 add_lldb_executable(lldb-argdumper
   argdumper.cpp
   )
 
-target_link_libraries(lldb-argdumper liblldb)
+if (LLDB_LINKER_SUPPORTS_GROUPS)
+  target_link_libraries(lldb-argdumper -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
+else()
+  target_link_libraries(lldb-argdumper ${LLDB_USED_LIBS})
+endif()
+llvm_config(lldb-argdumper ${LLVM_LINK_COMPONENTS})
+
 
 install(TARGETS lldb-argdumper
   RUNTIME DESTINATION bin)
Index: cmake/modules/AddLLDB.cmake
===================================================================
--- cmake/modules/AddLLDB.cmake
+++ cmake/modules/AddLLDB.cmake
@@ -4,7 +4,7 @@
   endif()
 
   if(${targetkind} MATCHES "SHARED")
-    set(LINK_KEYWORD ${cmake_2_8_12_PUBLIC})
+    set(LINK_KEYWORD ${cmake_2_8_12_PRIVATE})
   endif()
 
   if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
@@ -62,10 +62,10 @@
 
     if (PARAM_SHARED)
       if (LLDB_LINKER_SUPPORTS_GROUPS)
-        target_link_libraries(${name} ${cmake_2_8_12_PUBLIC}
+        target_link_libraries(${name} ${cmake_2_8_12_PRIVATE}
                     -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
       else()
-        target_link_libraries(${name} ${cmake_2_8_12_PUBLIC} ${CLANG_USED_LIBS})
+        target_link_libraries(${name} ${cmake_2_8_12_PRIVATE} ${CLANG_USED_LIBS})
       endif()
     endif()
     llvm_config(${name} ${LLVM_LINK_COMPONENTS})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16293.45175.patch
Type: text/x-patch
Size: 1633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160118/9eb483b7/attachment-0001.bin>


More information about the lldb-commits mailing list