[Lldb-commits] [lldb] [lldb][windows] recommend building with Python 3.11 (PR #191159)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 9 07:04:11 PDT 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/191159
>From ea153b11e65d2182c49787bf4cfae84104ea5c5c Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 9 Apr 2026 11:37:15 +0100
Subject: [PATCH 1/4] [lldb][windows] recommend building with Python 3.11
---
lldb/cmake/modules/FindPythonAndSwig.cmake | 5 ++++-
lldb/docs/resources/build.rst | 6 +++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake b/lldb/cmake/modules/FindPythonAndSwig.cmake
index b478038f144d9..e77615cba9017 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -66,8 +66,11 @@ else()
Python3_EXECUTABLE
LLDB_ENABLE_SWIG)
endif()
-
+if(WIN32)
+set(LLDB_RECOMMENDED_PYTHON "3.11")
+else()
set(LLDB_RECOMMENDED_PYTHON "3.8")
+endif()
if(PYTHONANDSWIG_FOUND AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} "
"is recommended and will be required from LLDB 21.")
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index f231aac5732a7..ca2937efd9d91 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -112,9 +112,9 @@ Please follow the steps below if you only want to **build** lldb.
``dirname`` are available from your terminal.
3. Install `make <https://sourceforge.net/projects/ezwinports/files/>`_ and
verify that it's in your ``PATH``.
-4. Install `Python 3 <https://www.python.org/downloads/windows/>`_. Either using
- the "Windows Installer" or "Python Install Manager". Make sure ``python`` is
- added to your ``PATH``.
+4. Install `Python 3.11 <https://www.python.org/downloads/windows/>`_ or newer.
+ Either using the "Windows Installer" or "Python Install Manager". Make sure
+ ``python`` is added to your ``PATH``.
.. note::
Building LLDB in debug mode requires a debug version of Python (because
>From f5db75a37625efab55f6ad92d16e4223e5eb8955 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 9 Apr 2026 14:32:00 +0100
Subject: [PATCH 2/4] force minimum Python version on Windows
---
lldb/cmake/modules/FindPythonAndSwig.cmake | 2 +-
.../Plugins/ScriptInterpreter/Python/lldb-python.h | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake b/lldb/cmake/modules/FindPythonAndSwig.cmake
index e77615cba9017..e23b6e4c0b18e 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -73,5 +73,5 @@ set(LLDB_RECOMMENDED_PYTHON "3.8")
endif()
if(PYTHONANDSWIG_FOUND AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} "
- "is recommended and will be required from LLDB 21.")
+ "is recommended and will be required from LLDB 23.")
endif()
\ No newline at end of file
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
index cf1e2836b78fb..a5c67e9ee51f4 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -39,7 +39,13 @@ static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
#include <locale>
#endif
-#define LLDB_MINIMUM_PYTHON_VERSION 0x03080000
+#ifdef _WIN32
+#define LLDB_MINIMUM_PYTHON_VERSION_HEX 0x030b0000
+#define LLDB_MINIMUM_PYTHON_VERSION "3.11"
+#else
+#define LLDB_MINIMUM_PYTHON_VERSION_HEX 0x03080000
+#define LLDB_MINIMUM_PYTHON_VERSION "3.8"
+#endif
#if LLDB_ENABLE_PYTHON_LIMITED_API
// If defined, LLDB will be ABI-compatible with all Python 3 releases from the
@@ -52,8 +58,8 @@ static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
// 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 >= LLDB_MINIMUM_PYTHON_VERSION,
- "LLDB requires at least Python 3.8");
+static_assert(PY_VERSION_HEX >= LLDB_MINIMUM_PYTHON_VERSION_HEX,
+ "LLDB requires at least Python " LLDB_MINIMUM_PYTHON_VERSION);
// PyMemoryView_FromMemory is part of stable ABI but the flag constants are not.
// See https://github.com/python/cpython/issues/98680
>From 3f93f02c83bd0ef67fdf65926f40ab73387c5277 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 9 Apr 2026 14:40:26 +0100
Subject: [PATCH 3/4] fixup! force minimum Python version on Windows
---
lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
index a5c67e9ee51f4..6b77024fe799b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -50,7 +50,7 @@ static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
#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
+#define Py_LIMITED_API LLDB_MINIMUM_PYTHON_VERSION_HEX
#endif
// Include python for non windows machines
>From 7da643b1d476a586f9a6a8a14180165e9f37f7cb Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 9 Apr 2026 15:03:52 +0100
Subject: [PATCH 4/4] update documentation
---
lldb/cmake/modules/FindPythonAndSwig.cmake | 9 ---------
lldb/docs/resources/build.rst | 18 +++++++++---------
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake b/lldb/cmake/modules/FindPythonAndSwig.cmake
index e23b6e4c0b18e..ca17a259967d4 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -66,12 +66,3 @@ else()
Python3_EXECUTABLE
LLDB_ENABLE_SWIG)
endif()
-if(WIN32)
-set(LLDB_RECOMMENDED_PYTHON "3.11")
-else()
-set(LLDB_RECOMMENDED_PYTHON "3.8")
-endif()
-if(PYTHONANDSWIG_FOUND AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
- message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} "
- "is recommended and will be required from LLDB 23.")
-endif()
\ No newline at end of file
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index ca2937efd9d91..aea461650e1a1 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -30,7 +30,7 @@ The following requirements are shared on all platforms.
If you want to run the test suite, you'll need to build LLDB with Python
scripting support.
-* `Python <http://www.python.org/>`_ 3.8 or later.
+* `Python <http://www.python.org/>`_ 3.8 or later (3.11 or later on Windows).
* `SWIG <http://swig.org/>`_ 4 or later.
If you are on FreeBSD or NetBSD, you will need to install ``gmake`` for building
@@ -52,19 +52,19 @@ disabled. When a dependency is set to ``On`` and can't be found it will cause a
CMake configuration error.
+-------------------+--------------------------------------------------------------+--------------------------+
-| Feature | Description | CMake Flag |
+| Feature | Description | CMake Flag |
+===================+==============================================================+==========================+
-| Editline | Generic line editing, history, Emacs and Vi bindings | ``LLDB_ENABLE_LIBEDIT`` |
+| Editline | Generic line editing, history, Emacs and Vi bindings | ``LLDB_ENABLE_LIBEDIT`` |
+-------------------+--------------------------------------------------------------+--------------------------+
-| Curses | Text user interface | ``LLDB_ENABLE_CURSES`` |
+| Curses | Text user interface | ``LLDB_ENABLE_CURSES`` |
+-------------------+--------------------------------------------------------------+--------------------------+
-| LZMA | Lossless data compression | ``LLDB_ENABLE_LZMA`` |
+| LZMA | Lossless data compression | ``LLDB_ENABLE_LZMA`` |
+-------------------+--------------------------------------------------------------+--------------------------+
-| Libxml2 | XML | ``LLDB_ENABLE_LIBXML2`` |
+| Libxml2 | XML | ``LLDB_ENABLE_LIBXML2`` |
+-------------------+--------------------------------------------------------------+--------------------------+
-| Python | Python scripting. >= 3.8 is required. | ``LLDB_ENABLE_PYTHON`` |
+| Python | Python scripting. >= 3.8 is required (3.11 or later on Windows). | ``LLDB_ENABLE_PYTHON`` |
+-------------------+--------------------------------------------------------------+--------------------------+
-| Lua | Lua scripting. Lua 5.3 and 5.4 are supported. | ``LLDB_ENABLE_LUA`` |
+| Lua | Lua scripting. Lua 5.3 and 5.4 are supported. | ``LLDB_ENABLE_LUA`` |
+-------------------+--------------------------------------------------------------+--------------------------+
Depending on your platform and package manager, one might run any of the
@@ -112,7 +112,7 @@ Please follow the steps below if you only want to **build** lldb.
``dirname`` are available from your terminal.
3. Install `make <https://sourceforge.net/projects/ezwinports/files/>`_ and
verify that it's in your ``PATH``.
-4. Install `Python 3.11 <https://www.python.org/downloads/windows/>`_ or newer.
+4. Install `Python 3.11 <https://www.python.org/downloads/windows/>`_ or later.
Either using the "Windows Installer" or "Python Install Manager". Make sure
``python`` is added to your ``PATH``.
More information about the lldb-commits
mailing list