RFC: Let's document (and enforce?) a minimum Python version for LLDB

Someone raised [lldb] Fix deprecation warning because of Py_SetPythonHome · Issue #113475 · llvm/llvm-project · GitHub recently and suggested it as a good first issue. The main reason I don’t think it is a good first issue is because we don’t document a minimum supported Python version and we don’t enforce one with CMake.

Instead we occasionally have a thread like this and Jonas tells us whether Mac OS is ready to upgrade yet :slight_smile:

So let’s agree on a minimum Python version to document on Building - 🐛 LLDB.

I’ve done a survey of the versions used or mentioned:

  • LLVM itself requires a minimum of 3.8 to run tests or 3.0 without tests (with a note that 3.0 may not actually work). Python is optional for lldb, so this is only a reference point not something we have to follow.
  • Building - 🐛 LLDB mentions a python36 package install for NetBSD. Could not confirm what current NetBSD uses.
  • The latest FreeBSD port of Python is 3.11 (FreshPorts -- lang/python3: Meta-port for the Python interpreter 3.x) but I do not know if the system lldb is built with Python. Also FreeBSD can have multiple Python versions installed.
  • The buildbots:
    • lldb-arm-ubuntu - 3.10
    • lldb-aarch64-ubuntu - 3.10
    • lldb-remote-linux-ubuntu - 3.12
    • lldb-x86_64-debian - 3.11
    • lldb-aarch64-windows - 3.11.9
  • Ubuntu system Python versions (python3-defaults package : Ubuntu):
    • Bionic - 3.6 (standard support ended 31 May 2023)
    • Focal - 3.8 (standard support ends April 2025)
    • Jammy - 3.10 (standard support ends April 2027)
    • Noble - 3.12 (standard support ends April 2029)
  • Mac OS? (@JDevlieghere)

With a minimum of 3.6. Though that is for NetBSD who may have moved on since and Ubuntu Bionic which is out of support.

Our code refers to versions 3.2, 3.3, 3.7, 3.9 and 3.13. If we have a set minimum then we can remove some of those #ifs.

I think it’s either 3.6 or 3.7 for our minimum version that is actually used somewhere.

3 Likes

FWIW
For LLVM Windows Release I plan to keep standard python per year on Windows. Move to 3.12.x from LLVM 20 onwards and will keep 3.12.x in LLVM 21 as well. Which actually means that we should now update LLVM buildbot to use python 3.12.x to make sure LLVM 20 runs smooth when its released.

We build LLVM Linux release builds on LTS - 1 (currently Jammy). I guess we dont have any known cases of LLDB being built on bionic anymore. So may be python 3.8 is safe bet for Linux.

On macOS, Python3 is included in the Xcode release. The past three years have been

2022, Xcode 14, Python 3.8 + 3.9
2023, Xcode 15, Python 3.9
2024, Xcode 16, Python 3.9

If people are locked on to older OSes that cannot update Xcode (Xcode runs on its matching macOS release, and the previous year’s macOS release, both the OS and Xcode are on an annual update schedule), they can install it from Homebrew packages, or build from source. I’m fine with a requirement of 3.9, as far as macOS is concerned.

2 Likes

Thanks for putting this together @DavidSpickett. I’m very supportive of documenting a minimum Python version. The transition from Python 2 to Python 3 was an “interesting” experience but luckily that’s fully behind us now.

As @jasonmolenda pointed out, the latest 3 Xcode releases have shipped with Python 3.9. My preference would be to match LLVM and require at least Python 3.8.

From a RHEL perspective, anything <= 3.9 is convenient for us, because that’s the system Python version on RHEL 9. On RHEL 8, it’s Python 3.6, but because the rest of LLVM requires a newer version, we end up using Python 3.12 instead anyway (which is less good for overall system integration, but not super important for lldb’s case).

I generally think it’s a good idea to have the same Python version requirement in lldb as for the rest of LLVM (so that would be Python 3.8 currently).

1 Like

Thanks @nikic I didn’t think to check Redhat.

https://apt.llvm.org/ goes back to Focal (3.8) for Ubuntu and Debian 10 (3.7, Python - Debian Wiki). Is that correct @sylvestre?

Maybe you are also using a minimum of 3.8 to match llvm.

This applies to lldb and its dependencies. So they could use Homebrew to install a newer Python first. The earliest one is 3.8 (python@3.13 — Homebrew Formulae), which is convenient.

this is correct

I’m building with and shipping Python 3.11.4 with my Hexagon and RISC-V toolchains. I’ll upgrade to 3.14 or 3.15 when 3.11 is end-of-life.

I chose 3.11 because it was the first release that officially supported ARM Windows, and we ship both Hexagon and RISC-V toolchains on ARM Windows.

1 Like

+1 for matching LLVM.

LLDB’s use case is somewhat… different from the rest of llvm, so I can imagine us moving forwards, if we have a good reason, but:
a) I’m not sure if have that right now
b) it definitely doesn’t make sense to require a lower version than llvm

Matching llvm makes sense, but I should emphasise that llvm requires 3.8 if and only if you enable tests:

I don’t know that llvm has anything linking against Python like we do.

If 3.8 is an ok minimum for us anyway, then this detail is not important.

Edit: Getting Started with the LLVM System — LLVM 20.0.0git documentation as well but it makes the same point as the CMake does.

If you disable tests, is python even used for anything in llvm? Some build time scripts perhaps? There’s certainly not many of them, so I can see how they could have a stricter (lower) version requirement.

And I think the same could be said for lldb: if we disable tests and linking with python, then our usage of python is very low, and if someone was motivated enough, then he could probably make that work with an earlier version without too much effort. So, given that llvm (at least the llvm subproject) does link against python, we could sort of say that we’re matching llvm (but maybe we also don’t have to – I think people build llvm in more constrained environments)

The minimum versions we can be sure of choosing:

  • Ubuntu (Focal) - 3.8
  • Windows on Arm - 3.11
  • Mac OS - 3.8
  • Redhat - 3.8

3.8 is the favourite right now.

I have sent out some emails to folks who can hopefully tell me what the BSDs use.

Windows x86 we are safe in assuming 3.8 will run there. We already have situations where people have to install specific Python’s there to use certain lldb builds (which is not ideal but out of scope for this thread).

Debian’s current LTS ships 3.9, but apt.llvm goes back to Debian 10 which is 3.7. @sylvestre , would a minimum of 3.8 be a problem for your Debian 10 builds? (I kinda asked this already but I didn’t phrase it properly the first time)

For enforcing the minimum, perhaps we start by warning for < 3.8 and recommending 3.8 in the documentation.

Once the 20 branch is taken, we make it a cmake error to have < 3.8, document it as the minimum and remove support code for anything older.

1 Like

I sent this by email to @DavidSpickett but might as well add it here for posterity.

For the copy of LLDB in the FreeBSD base system we provide (only) lua scripting, as we already have lua available and do not want to maintain Python as contrib code.

In the ports tree we have Python versions from 3.8 through 3.11. Our 3.8 port is expiring at the end of the year:

DEPRECATED=     Upgrade to a newer Python version. 3.8 is in
maintenance status and gets security fixes only. End-of-Life: 2024-10.
See https://devguide.python.org/versions/

LLDB using 3.8 as a minimum requirement is fine for FreeBSD.

1 Like

Thanks @emaste.

I also heard back from Brad Styles who said that:

OpenBSD uses Python 3.11 as the default. NetBSD uses Python 3.12 as the
default.

Once we have confirmation about llvm’s Debian 10 builds, I will go ahead with 3.8 as the minimum. Warning for 20, requirement for 21.

1 Like

There was some mix-up there. That is not my last name.

Sorry! Somehow I mixed up your first name and part of the domain name of your commit email.

2 Likes

[lldb] Make Python >= 3.8 required for LLDB 21 by DavidSpickett · Pull Request #124735 · llvm/llvm-project · GitHub is in review, in anticipation of the 20 branch happening soon.

1 Like

That PR was landed. Python 3.8 is now the minimum requirement.

1 Like