From fb5ce5db430f430f0403e1c989dd919e914d5803 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 27 Feb 2025 09:26:05 -0600 Subject: [PATCH] Allow enabling the JIT on macOS --- cpython-unix/build-cpython.sh | 10 ++++++---- cpython-unix/patch-jit-include-flags.patch | 12 ++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 cpython-unix/patch-jit-include-flags.patch diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index ea1b1c0a..e4d64599 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -427,11 +427,13 @@ if [ -n "${CPYTHON_OPTIMIZED}" ]; then # Allow users to enable the experimental JIT on 3.13+ if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]]; then + CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --enable-experimental-jit=yes-off" - # The JIT build is failing on macOS due to compiler errors - # Only enable on Linux / 3.13 until that's fixed upstream - if [[ "${PYBUILD_PLATFORM}" != "macos" ]]; then - CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --enable-experimental-jit=yes-off" + # The JIT build process is separate from the normal build and doesn't read our standard + # compiler flags so we need to patch our Clang toolchain into the includes. + # This is only necessary on macOS. + if [[ "${PYBUILD_PLATFORM}" = "macos" ]]; then + patch -p1 -i "${ROOT}/patch-jit-include-flags.patch" fi if [[ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_13}" ]]; then diff --git a/cpython-unix/patch-jit-include-flags.patch b/cpython-unix/patch-jit-include-flags.patch new file mode 100644 index 00000000..54e8555f --- /dev/null +++ b/cpython-unix/patch-jit-include-flags.patch @@ -0,0 +1,12 @@ +diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py +index 7eb433e2a5b..cd838daa8c5 100644 +--- a/Tools/jit/_targets.py ++++ b/Tools/jit/_targets.py +@@ -113,6 +113,7 @@ async def _compile( + "-D_PyJIT_ACTIVE", + "-D_Py_JIT", + "-I.", ++ f"-I${os.environ['TOOLS_PATH']}/deps/include", + f"-I{CPYTHON / 'Include'}", + f"-I{CPYTHON / 'Include' / 'internal'}", + f"-I{CPYTHON / 'Include' / 'internal' / 'mimalloc'}",