[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
This commit is contained in:
Lawrence D'Anna 2021-11-16 14:32:03 -08:00
parent 39e9f5d368
commit ae389b2450
3 changed files with 6 additions and 11 deletions

View File

@ -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}

View File

@ -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})

View File

@ -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}")