Skip to content

Commit 32fd69b

Browse files
encukoufreakboy3742ned-deily
authored
gh-153711: Test availability for dup3() and pipe2() on iOS (#155222)
Modifies the configure test for dup3 and pipe2 to allow for iOS. These symbols exist, but are unlinkable on iOS 26. Co-authored-by: Russell Keith-Magee <russell@keith-magee.com> Co-authored-by: Ned Deily <nad@python.org>
1 parent aeff4cb commit 32fd69b

5 files changed

Lines changed: 59 additions & 11 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
14791479
Return a pair of file descriptors ``(r, w)`` usable for reading and writing,
14801480
respectively.
14811481

1482-
.. availability:: Unix, macOS >= 27.0, not WASI, not iOS.
1482+
.. availability:: Unix, macOS >= 27.0, iOS >= 27.0, not WASI.
14831483

14841484
.. versionadded:: 3.3
14851485

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
On iOS, add :func:`os.pipe2`, and use the syscalls :manpage:`pipe2 (2)` and
2+
:manpage:`dup3 (2)` internally, when available at both build-time and
3+
run-time.

‎Modules/posixmodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ static const unsigned int _Py_STATX_KNOWN = (STATX_BASIC_STATS | STATX_BTIME
513513
# define HAVE_MKFIFOAT_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
514514
# define HAVE_MKNODAT_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
515515
# define HAVE_PTSNAME_R_RUNTIME __builtin_available(macOS 10.13.4, iOS 11.3, tvOS 11.3, watchOS 4.3, *)
516-
# define HAVE_DUP3_RUNTIME __builtin_available(macOS 27.0, *)
517-
# define HAVE_PIPE2_RUNTIME __builtin_available(macOS 27.0, *)
516+
# define HAVE_DUP3_RUNTIME __builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, visionOS 27.0, *)
517+
# define HAVE_PIPE2_RUNTIME __builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, visionOS 27.0, *)
518518

519519
# define HAVE_POSIX_SPAWN_SETSID_RUNTIME __builtin_available(macOS 10.15, *)
520520

‎configure‎

Lines changed: 34 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ if test -z "$AR"; then
439439
aarch64-apple-ios*) AR=arm64-apple-ios-ar ;;
440440
x86_64-apple-ios*-simulator) AR=x86_64-apple-ios-simulator-ar ;;
441441
*)
442-
esac
442+
esac
443443
fi
444444
if test -z "$CC"; then
445445
case "$host" in
@@ -5605,9 +5605,24 @@ fi
56055605
# found by configure), but either raise a compilation error (because the
56065606
# header definition prevents usage - autoconf doesn't use the headers), or
56075607
# raise an error if used at runtime. Force these symbols off.
5608-
if test "$ac_sys_system" != "iOS" ; then
5609-
AC_CHECK_FUNCS([dup3 getentropy getgroups pipe2 system])
5610-
fi
5608+
# In particular, dup3 and pipe2 are available as of iOS 27 but were
5609+
# incorrectly detected in older simulator versions.
5610+
case "$ac_sys_system" in
5611+
iOS)
5612+
AC_MSG_CHECKING([if iOS SDK is older than 27])
5613+
ios_sdk_version=$(xcrun --sdk iphoneos --show-sdk-version 2>/dev/null | cut -d. -f1)
5614+
if test -n "$ios_sdk_version" && test "$ios_sdk_version" -ge 27; then
5615+
AC_MSG_RESULT([no])
5616+
AC_CHECK_FUNCS([dup3 pipe2])
5617+
else
5618+
AC_MSG_RESULT([yes])
5619+
fi
5620+
;;
5621+
*)
5622+
# not iOS
5623+
AC_CHECK_FUNCS([dup3 getentropy getgroups pipe2 system])
5624+
;;
5625+
esac
56115626

56125627
AC_CHECK_DECL([dirfd],
56135628
[AC_DEFINE([HAVE_DIRFD], [1],

0 commit comments

Comments
 (0)