FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] GH-136895: Update JIT builds to use LLVM 21 (GH-140329) by mcepl · Pull Request #146420 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .bat  (1) .c  (1) .md  (1) .py  (1) .rst  (1) .yml  (2) All 6 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
GH-136895: Update JIT builds to use LLVM 21
Bump the JIT toolchain from LLVM 20 to LLVM 21 (21.1.8). Updated
across CI workflows, build scripts, documentation, and the externals
tag.
  • Loading branch information
mcepl committed Mar 25, 2026
commit 5477f5b3e6063aa8e265608ade7950eaa3cce7cf
2 changes: 1 addition & 1 deletion .github/workflows/jit.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ concurrency:

env:
FORCE_COLOR: 1
LLVM_VERSION: 20
LLVM_VERSION: 21

jobs:
interpreter:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tail-call.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:

env:
FORCE_COLOR: 1
LLVM_VERSION: 20
LLVM_VERSION: 21

jobs:
windows:
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Update JIT compilation to use LLVM 20 at build time.
Update JIT compilation to use LLVM 21 at build time.
2 changes: 1 addition & 1 deletion PCbuild/get_externals.bat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi-3.4.4
if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-3.0.19
if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.15.0
if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06
if NOT "%IncludeLLVM%"=="false" set binaries=%binaries% llvm-20.1.8.0
if NOT "%IncludeLLVM%"=="false" set binaries=%binaries% llvm-21.1.4.0

for %%b in (%binaries%) do (
if exist "%EXTERNALS_DIR%\%%b" (
Expand Down
2 changes: 1 addition & 1 deletion Python/jit.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void patch_x86_64_trampoline(unsigned char *location, int ordinal, jit_state *st
#define DATA_ALIGN 8
#elif defined(__x86_64__) || defined(_M_X64)
// x86_64 trampolines: 14 bytes (jmp *(%rip) + 8-byte addr) + 2 bytes padding.
// Currently used on macOS where LLVM 20 GOT entries may exceed ±2GB
// Currently used on macOS where LLVM 21 GOT entries may exceed ±2GB
// PC-relative range, but enabled on all x86_64 platforms defensively.
#define TRAMPOLINE_SIZE 16
#define DATA_ALIGN 8
Expand Down
20 changes: 10 additions & 10 deletions Tools/jit/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ Python 3.11 or newer is required to build the JIT.

The JIT compiler does not require end users to install any third-party dependencies, but part of it must be *built* using LLVM[^why-llvm]. You are *not* required to build the rest of CPython using LLVM, or even the same version of LLVM (in fact, this is uncommon).

LLVM version 20 is the officially supported version. You can modify if needed using the `LLVM_VERSION` env var during configure. Both `clang` and `llvm-readobj` need to be installed and discoverable (version suffixes, like `clang-19`, are okay). It's highly recommended that you also have `llvm-objdump` available, since this allows the build script to dump human-readable assembly for the generated code.
LLVM version 21 is the officially supported version. You can modify if needed using the `LLVM_VERSION` env var during configure. Both `clang` and `llvm-readobj` need to be installed and discoverable (version suffixes, like `clang-21`, are okay). It's highly recommended that you also have `llvm-objdump` available, since this allows the build script to dump human-readable assembly for the generated code.

It's easy to install all of the required tools:

### Linux

Install LLVM 20 on Ubuntu/Debian:
Install LLVM 21 on Ubuntu/Debian:

```sh
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
sudo ./llvm.sh 21
```

Install LLVM 20 on Fedora Linux 40 or newer:
Install LLVM 21 on Fedora Linux 40 or newer:

```sh
sudo dnf install 'clang(major) = 20' 'llvm(major) = 20'
sudo dnf install 'clang(major) = 21' 'llvm(major) = 21'
```

### macOS

Install LLVM 20 with [Homebrew](https://brew.sh):
Install LLVM 21 with [Homebrew](https://brew.sh):

```sh
brew install llvm@20
brew install llvm@21
```

Homebrew won't add any of the tools to your `$PATH`. That's okay; the build script knows how to find them.
Expand All @@ -43,18 +43,18 @@ Homebrew won't add any of the tools to your `$PATH`. That's okay; the build scri

LLVM is downloaded automatically (along with other external binary dependencies) by `PCbuild\build.bat`.

Otherwise, you can install LLVM 20 [by searching for it on LLVM's GitHub releases page](https://github.com/llvm/llvm-project/releases?q=20), clicking on "Assets", downloading the appropriate Windows installer for your platform (likely the file ending with `-win64.exe`), and running it. **When installing, be sure to select the option labeled "Add LLVM to the system PATH".**
Otherwise, you can install LLVM 21 [by searching for it on LLVM's GitHub releases page](https://github.com/llvm/llvm-project/releases?q=21), clicking on "Assets", downloading the appropriate Windows installer for your platform (likely the file ending with `-win64.exe`), and running it. **When installing, be sure to select the option labeled "Add LLVM to the system PATH".**

Alternatively, you can use [chocolatey](https://chocolatey.org):

```sh
choco install llvm --version=20.1.8
choco install llvm --version=21.1.8
```

### Dev Containers

If you are working on CPython in a [Codespaces instance](https://devguide.python.org/getting-started/setup-building/#using-codespaces), there's no
need to install LLVM as the Fedora 42 base image includes LLVM 20 out of the box.
need to install LLVM as the Fedora 42 base image includes LLVM 21 out of the box.

## Building

Expand Down
4 changes: 2 additions & 2 deletions Tools/jit/_llvm.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import _targets

_LLVM_VERSION = 20
_LLVM_VERSION = 21
_LLVM_VERSION_PATTERN = re.compile(rf"version\s+{_LLVM_VERSION}\.\d+\.\d+\S*\s+")
_EXTERNALS_LLVM_TAG = "llvm-20.1.8.0"
_EXTERNALS_LLVM_TAG = "llvm-21.1.4.0"

_P = typing.ParamSpec("_P")
_R = typing.TypeVar("_R")
Expand Down
Loading

Back | FazBrowse Home | New Git URL