pyenv/plugins/python-build/share/python-build/patches/3.10.15/Python-3.10.15/0002-downstream-3.10-gh-153711-Avoid-use-of-dup3-and-pipe.patch
native-api a99ef7fc4e
Backport XCode 27 support to 3.10 (#3549)
Adapted 3.11 downstream patch
2026-09-17 08:20:22 +03:00

110 lines
4.6 KiB
Diff

From 169cf06dbfe83862835225eb170e199d7060f5c0 Mon Sep 17 00:00:00 2001
From: Ned Deily <nad@python.org>
Date: Wed, 5 Aug 2026 10:30:17 +0300
Subject: [PATCH] (downstream) [3.10] gh-153711: Avoid use of dup3 and pipe2
calls introduced in macOS 27 (#155211)
---
...-08-05-02-02-33.gh-issue-153711.pO9fFb.rst | 3 +++
configure | 23 +++++++++++++++++--
configure.ac | 11 +++++++--
3 files changed, 33 insertions(+), 4 deletions(-)
create mode 100644 Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst
diff --git a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst
new file mode 100644
index 00000000000..90804c179a4
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst
@@ -0,0 +1,3 @@
+On macOS, do not attempt to use the :manpage:`dup3(2)` and
+:manpage:`pipe2(2)` system calls introduced in
+macOS 27 to prevent problems when running on older systems.
diff --git a/configure b/configure
index 4b71c4e00f8..bfe3e819fff 100755
--- a/configure
+++ b/configure
@@ -11952,7 +11952,7 @@ fi
# checks for library functions
for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
- clock confstr close_range copy_file_range ctermid dup3 execv explicit_bzero \
+ clock confstr close_range copy_file_range ctermid execv explicit_bzero \
explicit_memset faccessat fchmod fchmodat fchown fchownat \
fdwalk fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
futimens futimes gai_strerror getentropy \
@@ -11962,7 +11962,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
if_nameindex \
initgroups kill killpg lchown lockf linkat lstat lutimes mmap \
memrchr mbrtowc mkdirat mkfifo \
- madvise mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
+ madvise mkfifoat mknod mknodat mktime mremap nice openat pathconf pause plock poll \
posix_fallocate posix_fadvise posix_spawn posix_spawnp pread preadv preadv2 \
pthread_condattr_setclock pthread_init pthread_kill pwrite pwritev pwritev2 \
readlink readlinkat readv realpath renameat \
@@ -12005,6 +12005,25 @@ done
fi
+# macOS introduced dup3 and pipe2 in macOS 27, late in the
+# lifetime of this version of Python. Rather than adding weaklinking
+# support for them, just continue to ignore them.
+if test "$ac_sys_system" != "Darwin"; then
+ ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3"
+if test "x$ac_cv_func_dup3" = xyes
+then :
+ printf '%s\n' "#define HAVE_DUP3 1" >>confdefs.h
+
+fi
+ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2"
+if test "x$ac_cv_func_pipe2" = xyes
+then :
+ printf '%s\n' "#define HAVE_PIPE2 1" >>confdefs.h
+
+fi
+
+fi
+
ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include <sys/types.h>
#include <dirent.h>
"
diff --git a/configure.ac b/configure.ac
index ac3be3850a9..0b88132edfb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3708,7 +3708,7 @@ fi
# checks for library functions
AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
- clock confstr close_range copy_file_range ctermid dup3 execv explicit_bzero \
+ clock confstr close_range copy_file_range ctermid execv explicit_bzero \
explicit_memset faccessat fchmod fchmodat fchown fchownat \
fdwalk fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
futimens futimes gai_strerror getentropy \
@@ -3718,7 +3718,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
if_nameindex \
initgroups kill killpg lchown lockf linkat lstat lutimes mmap \
memrchr mbrtowc mkdirat mkfifo \
- madvise mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
+ madvise mkfifoat mknod mknodat mktime mremap nice openat pathconf pause plock poll \
posix_fallocate posix_fadvise posix_spawn posix_spawnp pread preadv preadv2 \
pthread_condattr_setclock pthread_init pthread_kill pwrite pwritev pwritev2 \
readlink readlinkat readv realpath renameat \
@@ -3740,6 +3740,13 @@ if test "$MACHDEP" != linux; then
AC_CHECK_FUNCS(lchmod)
fi
+# macOS introduced dup3 and pipe2 in macOS 27, late in the
+# lifetime of this version of Python. Rather than adding weaklinking
+# support for them, just continue to ignore them.
+if test "$ac_sys_system" != "Darwin"; then
+ AC_CHECK_FUNCS([dup3 pipe2])
+fi
+
AC_CHECK_DECL(dirfd,
AC_DEFINE(HAVE_DIRFD, 1,
Define if you have the 'dirfd' function or macro.), ,
--
2.55.0.windows.3