[Lldb-commits] [PATCH] D36885: [cmake] Explicitly link dependency libraries in the Host library

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 18 11:15:50 PDT 2017


mgorny created this revision.
mgorny added a project: LLDB.

Add explicit linkage to the necessary system libraries in the Host
library. Otherwise, the library fails to build with -Wl,--as-needed.
The system libraries ended up being listed on the linker command-line
before the static libraries needing them, resulting in --as-needed
stripping them.

Listing the dependent libraries explicitly is the canonical way of
declaring libraries in CMake. It guarantees that the system library
dependencies will be correctly propagated to reverse dependencies.

The code used to link libraries reuses existing EXTRA_LIBS variable,
copying code from other parts of LLDB. We might eventually remove
the direct use of system libraries in the programs; however, I would
prefer if we focused on fixing the build regressions in 5.0 branch
first, and went further after the release.


Repository:
  rL LLVM

https://reviews.llvm.org/D36885

Files:
  source/Host/CMakeLists.txt


Index: source/Host/CMakeLists.txt
===================================================================
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -156,9 +156,23 @@
   endif()
 endif()
 
+set(EXTRA_LIBS)
 if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
- set(EXTRA_LIBS kvm)
+  list(APPEND EXTRA_LIBS kvm)
 endif ()
+if (APPLE)
+  list(APPEND EXTRA_LIBS xml2)
+else ()
+  if (LIBXML2_FOUND)
+    list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  endif()
+endif ()
+if (HAVE_LIBDL)
+  list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
+endif()
+if (NOT LLDB_DISABLE_LIBEDIT)
+  list(APPEND EXTRA_LIBS edit)
+endif()
 
 add_lldb_library(lldbHost
   ${HOST_SOURCES}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36885.111708.patch
Type: text/x-patch
Size: 664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170818/c6392601/attachment.bin>


More information about the lldb-commits mailing list