Skip to content

[depends][python] fix the iOS simulator build - #29029

Merged
clementperon merged 2 commits into
xbmc:masterfrom
clementperon:fix-ios-python-simulator
Sep 9, 2026
Merged

clementperon merged 2 commits into
xbmc:masterfrom
clementperon:fix-ios-python-simulator

Conversation

@clementperon

Copy link
Copy Markdown
Contributor

Description

Python fails to build for the iOS Simulator. CPython's configure appends -mios-version-min — the device deployment-target flag — to CFLAGS/LDFLAGS for every iOS build, so against the simulator SDK the linker rejects the dylibs it resolves there:

ld: building for 'iOS', but linking in dylib (.../iPhoneSimulator18.2.sdk/usr/lib/libiconv.2.tbd) built for 'iOS-simulator'

-liconv is on LDFLAGS, so the very first compiler check fails and the depends build stops at configure: error: C compiler cannot create executables.

16-ios-platform.patch is also replaced here. Two thirds of it existed only to fake ac_sys_system=iOS: config.site.in pinned every package to the tree's darwin triplet, so CPython could never recognise the target itself, and the patch deleted its host-parsing logic wholesale. Letting python configure against its own iOS triplet removes 76 lines of that, and CPython then derives ac_sys_system, IPHONEOS_DEPLOYMENT_TARGET and the device/simulator split by itself.

What remains are three patches matching submissions under review upstream, named so they can be dropped once python is bumped past them:

Patch Upstream
16-ios-static-nonframework.patch python/cpython#156110
17-ios-simulator-version-min.patch python/cpython#156116
18-ios-objc-fallback.patch python/cpython#156113

The config.site.in change makes the tree's host triplet a default rather than an override, so a package that needs a different one can pass --host and have it survive. Nothing else in the tree passes --host, so no other package changes behaviour.

Motivation and context

The iOS Simulator leg of the E2E workflow has been red since #28808 landed, which introduced 16-ios-platform.patch. tvOS is unaffected — it builds as Darwin, so none of CPython's iOS-specific code runs.

How has this been tested?

Locally against Python 3.14.6 (the version this tree builds), with the three patches applied to a clean tarball plus the existing apple/static-compile/process-vm-ready patches — all apply with zero fuzz:

--host=aarch64-apple-ios12.0-simulator --disable-shared --disable-framework
  → exit 0, MACHDEP "ios", _PYTHON_HOST_PLATFORM=ios-12.0-arm64-iphonesimulator
  → CONFIGURE_CFLAGS … -mios-simulator-version-min=12.0

which is the check that previously failed. The full depends build and the Simulator E2E run are exercised by CI here.

Types of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation — no

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

The PR repairs Python’s iOS Simulator build by allowing a Python-specific iOS host triplet and applying separate upstream-oriented patches for static builds, simulator deployment flags, and Objective-C runtime loading.

  • Changes the target config site’s host values from overrides to defaults.
  • Generates CPython-native iOS device and simulator triplets.
  • Permits static, non-framework Python builds on iOS.
  • Selects the simulator-specific minimum-version flag where required.
  • Adds a fallback for loading the Objective-C runtime on older iOS versions.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failure identified.

The supported iOS host configurations produce triplets CPython parses into the intended deployment target and device type, while the static non-framework guards remain inactive for framework dependencies when frameworks are disabled.

Important Files Changed

Filename Overview
tools/depends/target/config.site.in Makes the standard cross-compilation host values defaults so an explicit package-level host triplet survives.
tools/depends/target/python3/Makefile Constructs valid CPython iOS triplets and applies the three focused iOS patches to iPhone targets.
tools/depends/target/python3/16-ios-static-nonframework.patch Allows static non-framework iOS builds while retaining rejection of unsupported shared non-framework builds.
tools/depends/target/python3/17-ios-simulator-version-min.patch Selects the deployment-target compiler and linker flag according to CPython’s parsed device type.
tools/depends/target/python3/18-ios-objc-fallback.patch Falls back to dyld resolution by library name and preserves the module’s ImportError contract if loading fails.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Depends HOST and target platform] --> B[Generate CPython iOS host triplet]
  B --> C[CPython derives iOS system, deployment target, and device type]
  C --> D{Simulator?}
  D -->|Yes| E[-mios-simulator-version-min]
  D -->|No| F[-mios-version-min]
  E --> G[Static non-framework Python build]
  F --> G
Loading

Reviews (1): Last reviewed commit: "fix(depends): build python for the iOS s..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@keithah

keithah commented Aug 20, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dece55012

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/depends/target/python3/16-ios-static-nonframework.patch
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 8dece55012

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread tools/depends/target/python3/16-ios-static-nonframework.patch Outdated
Comment thread tools/depends/target/config.site.in
@clementperon

Copy link
Copy Markdown
Contributor Author

Change Milestone to v23 IMO to risky and fix ios simulator not needed for v22

clementperon and others added 2 commits September 8, 2026 19:03
CPython appends -mios-version-min - the device flag - to every iOS build.
Against the simulator SDK the linker rejects the dylibs it resolves there, and
the first configure check that links one fails, taking the depends build with
it.

The local patch faked ac_sys_system=iOS by deleting CPython's host parsing,
because config.site.in pinned every package to the tree's darwin triplet. Python
now configures against its own iOS triplet, so CPython derives ac_sys_system,
the deployment target and the device/simulator split itself, and the 76 lines
that deleted that logic are gone.

What is left matches three patches under review upstream, so all three can be
dropped when python is next bumped:

  python/cpython#156110
  python/cpython#156116
  python/cpython#156113

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
python/cpython#156110, #156116 and #156113 all merged upstream, with small
changes made during review. Update the local patches to match exactly what
landed, and note in the Makefile that all three can be dropped once we bump
python past 3.16.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@clementperon
clementperon force-pushed the fix-ios-python-simulator branch from 53b1840 to fb0615b Compare September 8, 2026 17:03
@clementperon

Copy link
Copy Markdown
Contributor Author

@kambala-decapitator Python upstream has been merged.
Applied the new patch + rebase on top of master

@clementperon

Copy link
Copy Markdown
Contributor Author

@garbear I will merge it as it's a fix for the E2E CI that would be nice to have to support ios-simulator.
If it triggers any issue I will revert it

@clementperon
clementperon merged commit 2307c64 into xbmc:master Sep 9, 2026
1 of 2 checks passed
@clementperon
clementperon deleted the fix-ios-python-simulator branch September 9, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants