aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2025-08-05 08:16:36 -0700
committerGitHub <noreply@github.com>2025-08-05 08:16:36 -0700
commitfa39b67de01af189b59f9034ef6228a2951364b0 (patch)
tree6db8c2ebe82af086846315abc78c40708703de75 /lldb/source/Plugins/ScriptInterpreter/Python
parentae7be39601496aa8f712672844de82285a227646 (diff)
downloadllvm-fa39b67de01af189b59f9034ef6228a2951364b0.zip
llvm-fa39b67de01af189b59f9034ef6228a2951364b0.tar.gz
llvm-fa39b67de01af189b59f9034ef6228a2951364b0.tar.bz2
[lldb] Add a CMake option to build agains the Python limited API (#152034)
This adds a CMake option (which defaults to OFF) to force building against the Python limited API. This makes iterating on #151617 easier and eventually will prevent us from regressing this configuration.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
index 4a6c11d..9b4a1dd 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -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