[Lldb-commits] [lldb] ae389b2 - [lldb] use EXT_SUFFIX for python extension

Lawrence D'Anna via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 16 14:32:31 PST 2021


Author: Lawrence D'Anna
Date: 2021-11-16T14:32:26-08:00
New Revision: ae389b2450bd604a3f3bbe5b09b333b2d99801dd

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

LOG: [lldb] use EXT_SUFFIX for python extension

LLDB doesn't use only the python stable ABI, which means loading
it into an incompatible python can cause the process to crash.
_lldb.so should be named with the full EXT_SUFFIX from sysconfig
-- such as _lldb.cpython-39-darwin.so -- so this doesn't happen.

Reviewed By: JDevlieghere

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

Added: 
    

Modified: 
    lldb/CMakeLists.txt
    lldb/bindings/python/CMakeLists.txt
    lldb/bindings/python/get-python-config.py

Removed: 
    


################################################################################
diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 1a54addf3d557..c45064d9bef23 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -35,8 +35,10 @@ if (LLDB_ENABLE_PYTHON)
     "Path where Python modules are installed, relative to install prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
     "Path to python interpreter exectuable, relative to install prefix")
+  set(cachestring_LLDB_PYTHON_EXT_SUFFIX
+    "Filename extension for native code python modules")
 
-  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
+  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
     if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
       execute_process(
         COMMAND ${Python3_EXECUTABLE}

diff  --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt
index 5aabaf574636c..1f7ed18a2a0cb 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -149,15 +149,7 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
   else()
     set(LIBLLDB_SYMLINK_DEST "${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
   endif()
-  if(WIN32)
-    if(CMAKE_BUILD_TYPE STREQUAL Debug)
-      set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb_d.pyd")
-    else()
-      set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.pyd")
-    endif()
-  else()
-    set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.so")
-  endif()
+  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
   create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}
                           ${lldb_python_target_dir} ${LIBLLDB_SYMLINK_OUTPUT_FILE})
 

diff  --git a/lldb/bindings/python/get-python-config.py b/lldb/bindings/python/get-python-config.py
index 7acad6d2d4c9a..507a8aa072076 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -39,7 +39,8 @@ def main():
                         print("tried:", e, file=sys.stderr)
                     print("sys.prefix:", sys.prefix, file=sys.stderr)
                     sys.exit(1)
-
+    elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
+        print(sysconfig.get_config_var('EXT_SUFFIX'))
     else:
         parser.error(f"unknown variable {args.variable_name}")
 


        


More information about the lldb-commits mailing list