Author: mgorny Date: Mon Aug 21 10:41:33 2017 New Revision: 311354 URL: http://llvm.org/viewvc/llvm-project?rev=311354&view=rev Log: [cmake] Explicitly link dependency libraries in the Host library
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. Differential Revision: https://reviews.llvm.org/D36885 Modified: lldb/trunk/source/Host/CMakeLists.txt Modified: lldb/trunk/source/Host/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=311354&r1=311353&r2=311354&view=diff ============================================================================== --- lldb/trunk/source/Host/CMakeLists.txt (original) +++ lldb/trunk/source/Host/CMakeLists.txt Mon Aug 21 10:41:33 2017 @@ -156,9 +156,23 @@ if (${get_python_libdir}) 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} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits