Skip to content

[lldb] Add a CMake option to build agains the Python limited API #152034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
option(LLDB_ENABLE_PROTOCOL_SERVERS "Enable protocol servers (e.g. MCP) in LLDB" ON)
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)" OFF)
option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries" OFF)
option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing (Darwin only)." OFF)
option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing lldb." OFF)
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Host/Config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

#cmakedefine01 LLDB_ENABLE_PYTHON

#cmakedefine01 LLDB_ENABLE_PYTHON_LIMITED_API

#cmakedefine01 LLDB_ENABLE_FBSDVMCORE

#cmakedefine01 LLDB_EMBED_PYTHON_HOME
Expand Down
10 changes: 9 additions & 1 deletion lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
#include <locale>
#endif

#define LLDB_MINIMUM_PYTHON_VERSION 0x03080000

#if LLDB_ENABLE_PYTHON_LIMITED_API
// If defined, LLDB will be ABI-compatible with all Python 3 releases from the
// specified one onward, and can use Limited API introduced up to that version.
#define Py_LIMITED_API LLDB_MINIMUM_PYTHON_VERSION
#endif

// Include python for non windows machines
#include <Python.h>

// Provide a meaningful diagnostic error if someone tries to compile this file
// with a version of Python we don't support.
static_assert(PY_VERSION_HEX >= 0x03080000,
static_assert(PY_VERSION_HEX >= LLDB_MINIMUM_PYTHON_VERSION,
"LLDB requires at least Python 3.8");
#endif

Expand Down
Loading