Author: Fangrui Song
Date: 2020-01-06T10:01:55-08:00
New Revision: bbfebd7b8a671c9649305b8a5f72e93dd1ef60e1

URL: 
https://github.com/llvm/llvm-project/commit/bbfebd7b8a671c9649305b8a5f72e93dd1ef60e1
DIFF: 
https://github.com/llvm/llvm-project/commit/bbfebd7b8a671c9649305b8a5f72e93dd1ef60e1.diff

LOG: [CMake] Add $ORIGIN/../../../../lib to rpath if BUILD_SHARED_LIBS or 
LLVM_LINK_LLVM_DYLIB on *nix

Summary:
lib/python2.7/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
which depends on lib/libLLVM*.so (-DBUILD_SHARED_LIBS=ON) or 
lib/libLLVM-10git.so
(-DLLVM_LINK_LLVM_DYLIB=ON). Add an additional rpath `$ORIGIN/../../../../lib` 
so
that _lldb.so can be loaded from Python.

This fixes an import error from lib/python2.7/dist-packages/lldb/__init__.py

  from . import _lldb
  ImportError: libLLVMAArch64CodeGen.so.10git: cannot open shared object file: 
No such file or directory

 The following configurations will work:

* -DBUILD_SHARED_LIBS=ON
* -DBUILD_SHARED_LIBS=OFF -DLLVM_LINK_LLVM_DYLIB=ON
* -DBUILD_SHARED_LIBS=OFF -DLLVM_LINK_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON
  (-DCLANG_LINK_CLANG_DYLIB=ON depends on -DLLVM_LINK_LLVM_DYLIB=ON)

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D71800

Added: 
    

Modified: 
    lldb/source/API/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index d036caf2f434..eea409bed185 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -111,6 +111,14 @@ add_lldb_library(liblldb SHARED ${option_framework}
   ${option_install_prefix}
 )
 
+# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
+# which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so
+# (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so
+# that _lldb.so can be loaded from Python.
+if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX 
AND NOT APPLE)
+  set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH 
"\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
+endif()
+
 if (MSVC)
   set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
 endif()


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to