Skip to content

gh-156109: Allow static, non-framework iOS builds - #156110

Open
clementperon wants to merge 2 commits into
python:mainfrom
clementperon:ios-static-nonframework
Open

gh-156109: Allow static, non-framework iOS builds#156110
clementperon wants to merge 2 commits into
python:mainfrom
clementperon:ios-static-nonframework

Conversation

@clementperon

@clementperon clementperon commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

configure refuses any non-framework iOS build. That is correct for a shared Python — an iOS app can only load a signed framework, never a bare dylib — but a --disable-shared build produces a libpython3.x.a that is linked into the app binary and loads nothing at runtime, so the requirement does not apply to it.

This narrows the refusal to the combination that genuinely cannot work, and stops two Makefile variables referencing a framework that a non-framework build never produces.

  • The explicit --disable-framework path no longer errors on iOS; it falls through to the existing non-framework setup.
  • A new check, placed once PY_ENABLE_SHARED is known, rejects a shared build with no framework.
  • LINKFORSHARED and MODULE_DEPS_SHARED gate their $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK) appends on enable_framework, as the Darwin arm directly above the first one already does.
  • Passing no framework option at all still errors, so a non-framework build stays an explicit opt-in. Its message now names --disable-framework.

Verified on macOS/arm64 against main:

Configure (--host=arm64-apple-ios12.0) Result
--disable-framework --disable-shared configures; make libpython3.16.a succeeds — arm64, LC_BUILD_VERSION platform 2, minos 12.0
--disable-framework --enable-shared rejected: iOS builds must use --enable-framework, or --disable-shared to build a static libpython
no framework option rejected: iOS builds must use --enable-framework, or --disable-framework to build a static libpython
--enable-framework Makefile and pyconfig.h byte-identical to unpatched main

configure was regenerated with Tools/build/regen-configure.sh; autoreconf -ivf -Werror is clean and the generated diff contains no unrelated churn.

An iOS app can only load a signed framework, so a shared Python has to be built
as one. A static libpython is linked into the app binary and loads nothing at
runtime, so the requirement does not apply to it, but configure refused that
configuration outright.

Refuse it only where it cannot work: a shared build with no framework. The
LINKFORSHARED and MODULE_DEPS_SHARED framework references are gated on
enable_framework, as the Darwin arm above already does, since a build without a
framework has nothing to link against. Passing no framework option at all still
errors, so a non-framework build stays an explicit opt-in.
@clementperon
clementperon force-pushed the ios-static-nonframework branch from 82788a4 to e710088 Compare August 20, 2026 13:37
clementperon added a commit to clementperon/xbmc that referenced this pull request Aug 20, 2026
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>
clementperon added a commit to clementperon/xbmc that referenced this pull request Aug 20, 2026
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>
clementperon added a commit to clementperon/xbmc that referenced this pull request Aug 20, 2026
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>
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.

2 participants