Skip to content

Commit 52c9489

Browse files
authored
[lldb] Use the Python limited API with SWIG 4.2 or later (#153119) (#153472)
Use the Python limited API when building with SWIG 4.2 or later.
1 parent 8a0c7e9 commit 52c9489

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in
6868
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
6969
option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
7070
option(LLDB_ENABLE_PROTOCOL_SERVERS "Enable protocol servers (e.g. MCP) in LLDB" ON)
71-
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)" OFF)
7271
option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries" OFF)
7372
option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing (Darwin only)." OFF)
7473
option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing lldb." OFF)
@@ -174,11 +173,20 @@ if (LLDB_ENABLE_PYTHON)
174173
${default_embed_python_home})
175174

176175
include_directories(${Python3_INCLUDE_DIRS})
176+
177177
if (LLDB_EMBED_PYTHON_HOME)
178178
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
179179
set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
180180
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
181181
endif()
182+
183+
if (SWIG_VERSION VERSION_GREATER_EQUAL "4.2" AND NOT LLDB_EMBED_PYTHON_HOME)
184+
set(default_enable_python_limited_api ON)
185+
else()
186+
set(default_enable_python_limited_api OFF)
187+
endif()
188+
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)"
189+
${default_enable_python_limited_api})
182190
endif()
183191

184192
if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)

0 commit comments

Comments
 (0)