[Lldb-commits] [lldb] r239007 - [lldb] Enable building with Cmake/BUILD_SHARED_LIBS

Andrew Wilkins axwalk at gmail.com
Wed Jun 3 20:12:37 PDT 2015


Author: axw
Date: Wed Jun  3 22:12:37 2015
New Revision: 239007

URL: http://llvm.org/viewvc/llvm-project?rev=239007&view=rev
Log:
[lldb] Enable building with Cmake/BUILD_SHARED_LIBS

Summary:
Several changes to fix CMake builds of LLDB with the
BUILD_SHARED_LIBS setting on.

- Force all internal libraries to be built STATIC.
- Add additional library dependencies (pthread, dl,
  runtimedyld).
- modify finalisation of SWIG wrapper to symlink the
  "lib" dir into python/site-packages, so _lldb.so's
  RPATH resolves.

Test Plan: Verified one test case with "dotest.py".

Reviewers: sylvestre.ledru, zturner

Reviewed By: zturner

Subscribers: zturner, ted, tberghammer, emaste, lldb-commits

Differential Revision: http://reviews.llvm.org/D10157

Modified:
    lldb/trunk/cmake/LLDBDependencies.cmake
    lldb/trunk/cmake/modules/AddLLDB.cmake
    lldb/trunk/cmake/modules/LLDBConfig.cmake
    lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
    lldb/trunk/tools/lldb-server/CMakeLists.txt

Modified: lldb/trunk/cmake/LLDBDependencies.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=239007&r1=239006&r2=239007&view=diff
==============================================================================
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Wed Jun  3 22:12:37 2015
@@ -169,6 +169,7 @@ set( LLVM_LINK_COMPONENTS
   core
   mcdisassembler
   executionengine
+  runtimedyld
   option
   support
   )

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=239007&r1=239006&r2=239007&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Jun  3 22:12:37 2015
@@ -44,13 +44,14 @@ macro(add_lldb_library name)
     set(libkind MODULE)
   elseif (PARAM_SHARED)
     set(libkind SHARED)
-  elseif (PARAM_STATIC)
-    set(libkind STATIC)
   elseif (PARAM_OBJECT)
     set(libkind OBJECT)
   else ()
-    # library type unspecified - controlled by BUILD_SHARED_LIBS
-    unset(libkind)
+    # PARAM_STATIC or library type unspecified. BUILD_SHARED_LIBS
+    # does not control the kind of libraries created for LLDB,
+    # only whether or not they link to shared/static LLVM/Clang
+    # libraries.
+    set(libkind STATIC)
   endif()
 
   #PIC not needed on Win

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=239007&r1=239006&r2=239007&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Wed Jun  3 22:12:37 2015
@@ -219,6 +219,14 @@ else()
 
 endif()
 
+if (HAVE_LIBPTHREAD)
+  list(APPEND system_libs pthread)
+endif(HAVE_LIBPTHREAD)
+
+if (HAVE_LIBDL)
+  list(APPEND system_libs ${CMAKE_DL_LIBS})
+endif()
+
 if(LLDB_REQUIRES_EH)
   set(LLDB_REQUIRES_RTTI ON)
 else()

Modified: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finishSwigPythonLLDB.py?rev=239007&r1=239006&r2=239007&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py (original)
+++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py Wed Jun  3 22:12:37 2015
@@ -304,6 +304,8 @@ def make_symlink( vDictArgs, vstrFramewo
             # llvm/build/lib/python2.7/site-packages/lldb
             strBuildDir = os.path.join("..", "..", "..", "..");
         strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile));
+        strTargetDir = os.path.dirname(strTarget);
+        strSrc = os.path.relpath(os.path.abspath(strSrc), strTargetDir);
 
     if eOSType == utilsOsType.EnumOsType.Unknown:
         bOk = False;
@@ -371,6 +373,13 @@ def make_symlink_liblldb( vDictArgs, vst
                 strLibFileExtn = ".so";
             strSrc = os.path.join("lib", "liblldb" + strLibFileExtn);
 
+    if eOSType != utilsOsType.EnumOsType.Windows:
+        # Create a symlink to the "lib" directory, to ensure liblldb's RPATH is
+        # effective.
+        bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, "lib", os.path.join("../lib") );
+        if not bOk:
+            return (bOk, strErrMsg)
+
     bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
 
     return (bOk, strErrMsg);

Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=239007&r1=239006&r2=239007&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Wed Jun  3 22:12:37 2015
@@ -29,6 +29,9 @@ if (BUILD_SHARED_LIBS )
     )
 
   target_link_libraries(lldb-server liblldb)
+  if (HAVE_LIBPTHREAD)
+    target_link_libraries(lldb-server pthread)
+  endif ()
 else()
   add_lldb_executable(lldb-server
     lldb-gdbserver.cpp





More information about the lldb-commits mailing list