Skip to content

Commit ae389b2

Browse files
[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
1 parent 39e9f5d commit ae389b2

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

lldb/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ if (LLDB_ENABLE_PYTHON)
3535
"Path where Python modules are installed, relative to install prefix")
3636
set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
3737
"Path to python interpreter exectuable, relative to install prefix")
38+
set(cachestring_LLDB_PYTHON_EXT_SUFFIX
39+
"Filename extension for native code python modules")
3840

39-
foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
41+
foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
4042
if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
4143
execute_process(
4244
COMMAND ${Python3_EXECUTABLE}

lldb/bindings/python/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,7 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
149149
else()
150150
set(LIBLLDB_SYMLINK_DEST "${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
151151
endif()
152-
if(WIN32)
153-
if(CMAKE_BUILD_TYPE STREQUAL Debug)
154-
set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb_d.pyd")
155-
else()
156-
set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.pyd")
157-
endif()
158-
else()
159-
set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.so")
160-
endif()
152+
set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
161153
create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}
162154
${lldb_python_target_dir} ${LIBLLDB_SYMLINK_OUTPUT_FILE})
163155

lldb/bindings/python/get-python-config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def main():
3939
print("tried:", e, file=sys.stderr)
4040
print("sys.prefix:", sys.prefix, file=sys.stderr)
4141
sys.exit(1)
42-
42+
elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
43+
print(sysconfig.get_config_var('EXT_SUFFIX'))
4344
else:
4445
parser.error(f"unknown variable {args.variable_name}")
4546

0 commit comments

Comments
 (0)