From d856402e7176e5a03c5c578f0efc1be968be3257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Sat, 22 Aug 2026 05:05:20 +0200 Subject: [PATCH 1/2] gh-156115: Use the simulator deployment-target flag for iOS simulator builds (#156116) Ensures that CFLAGS and LDFLAGS use -mios-simulator-version-min, rather than the device-based -mios-version-min. This only matters if the CFLAGS and LDFLAGS are used in a bare call to clang without a -target; but that is a legal usage, so it's worth catching. --- .../Build/2026-08-20-14-02-33.gh-issue-156115.KXr8wU.rst | 4 ++++ configure | 9 +++++++-- configure.ac | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-08-20-14-02-33.gh-issue-156115.KXr8wU.rst diff --git a/Misc/NEWS.d/next/Build/2026-08-20-14-02-33.gh-issue-156115.KXr8wU.rst b/Misc/NEWS.d/next/Build/2026-08-20-14-02-33.gh-issue-156115.KXr8wU.rst new file mode 100644 index 000000000000000..612180d3b65db21 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-08-20-14-02-33.gh-issue-156115.KXr8wU.rst @@ -0,0 +1,4 @@ +iOS simulator builds are now configured with +``-mios-simulator-version-min`` instead of the device's +``-mios-version-min``. The device flag made the linker reject libraries +resolved from the simulator SDK, so library detection silently failed. diff --git a/configure b/configure index ea560d600722592..1b03d29e91a8336 100755 --- a/configure +++ b/configure @@ -4895,8 +4895,13 @@ case $host in #( ;; esac -case $ac_sys_system in #( - iOS) : +case $host in #( + *-apple-ios*-simulator) : + + as_fn_append CFLAGS " -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" + as_fn_append LDFLAGS " -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" + ;; #( + *-apple-ios*) : as_fn_append CFLAGS " -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" as_fn_append LDFLAGS " -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" diff --git a/configure.ac b/configure.ac index 7dfc6ca29297a8b..99444990cf0c741 100644 --- a/configure.ac +++ b/configure.ac @@ -1006,8 +1006,12 @@ AS_CASE([$host], ) dnl Add the compiler flag for the iOS minimum supported OS version. -AS_CASE([$ac_sys_system], - [iOS], [ +AS_CASE([$host], + [*-apple-ios*-simulator], [ + AS_VAR_APPEND([CFLAGS], [" -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) + AS_VAR_APPEND([LDFLAGS], [" -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) + ], + [*-apple-ios*], [ AS_VAR_APPEND([CFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) AS_VAR_APPEND([LDFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) ], From 918fb3aec907baf8d9b6181570ff308529be16a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Sat, 22 Aug 2026 05:51:49 +0200 Subject: [PATCH 2/2] gh-156112: Load the ObjC runtime by name when find_library() cannot resolve it (#156113) Provides a fallback name for the ObjC runtime library on iOS, and improved error handling when that library cannot be loaded. --- Lib/_ios_support.py | 13 ++++++++----- .../2026-08-20-13-50-49.gh-issue-156112.yEcma8.rst | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-08-20-13-50-49.gh-issue-156112.yEcma8.rst diff --git a/Lib/_ios_support.py b/Lib/_ios_support.py index 20467a7c2bcaeb0..cc51aa504916e36 100644 --- a/Lib/_ios_support.py +++ b/Lib/_ios_support.py @@ -10,12 +10,15 @@ else: # ctypes is available. Load the ObjC library, and wrap the objc_getClass, # sel_registerName methods - lib = util.find_library("objc") - if lib is None: - # Failed to load the objc library - raise ImportError("ObjC runtime library couldn't be loaded") + # find_library() resolves a system library through the dyld shared cache, + # which needs _dyld_shared_cache_contains_path(); that is unavailable before + # iOS 14, so fall back to the bare name, which dyld resolves by itself. + lib = util.find_library("objc") or "libobjc.dylib" - objc = cdll.LoadLibrary(lib) + try: + objc = cdll.LoadLibrary(lib) + except OSError: + raise ImportError("ObjC runtime library couldn't be loaded") objc.objc_getClass.restype = c_void_p objc.objc_getClass.argtypes = [c_char_p] objc.sel_registerName.restype = c_void_p diff --git a/Misc/NEWS.d/next/Library/2026-08-20-13-50-49.gh-issue-156112.yEcma8.rst b/Misc/NEWS.d/next/Library/2026-08-20-13-50-49.gh-issue-156112.yEcma8.rst new file mode 100644 index 000000000000000..ba92df3c5cb6c1d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-20-13-50-49.gh-issue-156112.yEcma8.rst @@ -0,0 +1,4 @@ +:mod:`!_ios_support` no longer fails to import when +:func:`ctypes.util.find_library` cannot resolve the ObjC runtime through the +dyld shared cache, as is the case on iOS 13. The runtime is now loaded by name, +which dyld resolves against the cache directly.