https://github.com/python/cpython/commit/2392232ec49ccabeb029b4507eeeab067065b889
commit: 2392232ec49ccabeb029b4507eeeab067065b889
branch: 3.14
author: Ned Deily <n...@python.org>
committer: hugovk <1324225+hug...@users.noreply.github.com>
date: 2025-08-13T13:37:01+03:00
summary:

[3.14] GH-134291: Support older macOS deployment targets for JIT builds 
(GH-137211) (#137701)

Co-authored-by: Brandt Bucher <brandtbuc...@microsoft.com>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2025-07-28-19-11-34.gh-issue-134291.IiB9Id.rst
M .github/workflows/jit.yml
M Python/jit.c

diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml
index 116e0c1e945e38..2a77661609f95b 100644
--- a/.github/workflows/jit.yml
+++ b/.github/workflows/jit.yml
@@ -113,6 +113,10 @@ jobs:
           find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' 
-delete
           brew install llvm@${{ matrix.llvm }}
           export SDKROOT="$(xcrun --show-sdk-path)"
+          # Set MACOSX_DEPLOYMENT_TARGET and -Werror=unguarded-availability to
+          # make sure we don't break downstream distributors (like uv):
+          export CFLAGS_JIT='-Werror=unguarded-availability'
+          export MACOSX_DEPLOYMENT_TARGET=10.15
           ./configure --enable-experimental-jit --enable-universalsdk 
--with-universal-archs=universal2 ${{ matrix.debug && '--with-pydebug' || '' }}
           make all --jobs 4
           ./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 
--verbose3
diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2025-07-28-19-11-34.gh-issue-134291.IiB9Id.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-28-19-11-34.gh-issue-134291.IiB9Id.rst
new file mode 100644
index 00000000000000..1605bcc3574148
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-28-19-11-34.gh-issue-134291.IiB9Id.rst
@@ -0,0 +1,2 @@
+Remove some newer macOS API usage from the JIT compiler in order to restore
+compatibility with older OSX 10.15 deployment targets.
diff --git a/Python/jit.c b/Python/jit.c
index e232cc1f7d9250..9fbd8a18590411 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -69,10 +69,6 @@ jit_alloc(size_t size)
 #else
     int flags = MAP_ANONYMOUS | MAP_PRIVATE;
     int prot = PROT_READ | PROT_WRITE;
-# ifdef MAP_JIT
-    flags |= MAP_JIT;
-    prot |= PROT_EXEC;
-# endif
     unsigned char *memory = mmap(NULL, size, prot, flags, -1, 0);
     int failed = memory == MAP_FAILED;
 #endif
@@ -118,11 +114,8 @@ mark_executable(unsigned char *memory, size_t size)
     int old;
     int failed = !VirtualProtect(memory, size, PAGE_EXECUTE_READ, &old);
 #else
-    int failed = 0;
     __builtin___clear_cache((char *)memory, (char *)memory + size);
-#ifndef MAP_JIT
-    failed = mprotect(memory, size, PROT_EXEC | PROT_READ);
-#endif
+    int failed = mprotect(memory, size, PROT_EXEC | PROT_READ);
 #endif
     if (failed) {
         jit_error("unable to protect executable memory");
@@ -528,9 +521,6 @@ _PyJIT_Compile(_PyExecutorObject *executor, const 
_PyUOpInstruction trace[], siz
     if (memory == NULL) {
         return -1;
     }
-#ifdef MAP_JIT
-    pthread_jit_write_protect_np(0);
-#endif
     // Collect memory stats
     OPT_STAT_ADD(jit_total_memory_size, total_size);
     OPT_STAT_ADD(jit_code_size, code_size);
@@ -568,9 +558,6 @@ _PyJIT_Compile(_PyExecutorObject *executor, const 
_PyUOpInstruction trace[], siz
     data += group->data_size;
     assert(code == memory + code_size);
     assert(data == memory + code_size + state.trampolines.size + data_size);
-#ifdef MAP_JIT
-    pthread_jit_write_protect_np(1);
-#endif
     if (mark_executable(memory, total_size)) {
         jit_free(memory, total_size);
         return -1;

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to