On Fedora 40+ x86_64 and aarch64, build Python with the experimental JIT compiler

This commit is contained in:
Miro Hrončok 2024-05-12 19:32:37 +02:00
commit f1315eaf0b
2 changed files with 75 additions and 3 deletions

View file

@ -17,7 +17,7 @@ URL: https://www.python.org/
%global prerel b2
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 3%{?dist}
Release: 4%{?dist}
License: Python-2.0.1
@ -138,6 +138,22 @@ Provides: bundled(python3dist(packaging)) = 24
# (the -freethreading subpackage)
%bcond_without freethreading_build
# PEP 744: JIT Compilation
# Whether to build with the experimental JIT compiler
# We can only have this on Fedora 40+, where clang 18+ is available
# And only on certain architectures: https://peps.python.org/pep-0744/#support
# The freethreading build (when enabled) does not support JIT yet
%bcond_with jit
%ifarch x86_64 aarch64
%if 0%{?fedora} >= 40 || 0%{?rhel} >= 10
%bcond_without jit
%endif
%endif
%if %{with jit}
# When built with JIT, it still needs to be enabled on runtime via PYTHON_JIT=1
%global jit_flag --enable-experimental-jit=yes-off
%endif
# Support for the GDB debugger
%bcond_without gdb_hooks
@ -299,6 +315,11 @@ BuildRequires: tcl-devel
BuildRequires: tk-devel
BuildRequires: tzdata
%if %{with jit}
BuildRequires: clang(major) = 18
BuildRequires: llvm(major) = 18
%endif
%if %{with valgrind}
BuildRequires: valgrind-devel
%endif
@ -373,6 +394,12 @@ Source11: idle3.appdata.xml
# pypa/distutils integration: https://github.com/pypa/distutils/pull/70
Patch251: 00251-change-user-install-location.patch
# 00429 # fa7831be5e5365646d4dd400e23e977f83f64923
# GH-118943: Fix another race condition when generating jit_stencils.h
#
# Another process might have already moved jit_stencils.h.new
Patch429: 00429-gh-118943-fix-another-race-condition-when-generating-jit_stencils-h.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@ -906,12 +933,12 @@ BuildPython() {
# option produces too many warnings when compiling at the O0 optimization level.
# See also: https://bugzilla.redhat.com/show_bug.cgi?id=1818857
BuildPython debug \
"--without-ensurepip --with-pydebug" \
"--without-ensurepip --with-pydebug %{?jit_flag}" \
"%{optflags_debug}"
%endif # with debug_build
BuildPython optimized \
"--without-ensurepip %{optimizations_flag}" \
"--without-ensurepip %{?jit_flag} %{optimizations_flag}" \
"%{optflags_optimized}"
%if %{with freethreading_build} && %{with debug_build}
@ -1687,6 +1714,11 @@ CheckPython freethreading
# ======================================================
%changelog
* Tue Jun 18 2024 Miro Hrončok <mhroncok@redhat.com> - 3.13.0~b2-4
- On Fedora 40+ x86_64 and aarch64, build Python with the experimental JIT compiler
- To enable it on runtime, set the PYTHON_JIT environment variable to 1
- https://peps.python.org/pep-0744/
* Thu Jun 06 2024 Python Maint <python-maint@redhat.com> - 3.13.0~b2-3
- Rebuilt for Python 3.13