python / python/cpython

Allow static, non-framework iOS builds

未關閉
#156,109 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

build OS-ios type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:

configure refuses any iOS build that is not a framework build, in both the explicit and the default path:

configure.ac:582   iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;   # --disable-framework
configure.ac:692   iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;   # no framework option given

The requirement is sound for a shared Python: an iOS app can only load a signed framework, never a bare dylib, so a dynamically loaded libpython has to be packaged as one. It does not hold for a static one. A --disable-shared build produces libpython3.x.a, which is linked into the app binary and loads nothing at runtime, so there is no framework to sign, package or load — but configure rejects that configuration before it can be attempted.

This matters for embedders, which link libpython statically into a single signed executable. Today they have to either patch configure locally or give up sys.platform == "ios" and cross-build as Darwin, which misreports the platform to the stdlib.

Two other places assume the framework exists whenever ac_sys_system is iOS:

configure.ac:3838  LINKFORSHARED="… $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)"
configure.ac:6767  MODULE_DEPS_SHARED="… $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)"

The Darwin arm immediately above the first one already guards the identical append with if test "$enable_framework"; the iOS arm does it unconditionally.

Suggested shape, keeping the change conservative:

  • refuse only the combination that genuinely cannot work — a shared build with no framework — checked once PY_ENABLE_SHARED is known;
  • gate the two framework appends on enable_framework, matching the Darwin arm;
  • leave the default path (no framework option at all) erroring, so a non-framework build stays an explicit opt-in, with the message naming --disable-framework.

I have this working against main and will open a PR. Verified locally on macOS/arm64:

  • --host=arm64-apple-ios12.0 --disable-shared --disable-framework configures and make libpython3.16.a succeeds, producing an arm64 archive with LC_BUILD_VERSION platform 2, minos 12.0;
  • --disable-framework --enable-shared is rejected with the new message;
  • no framework option is still rejected;
  • --enable-framework produces a byte-identical Makefile and pyconfig.h to unpatched main, so the supported framework build is unaffected.
Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-156110

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 configure.ac 的第 582、692、3838 和 6767 行開始,然後將 iOS 的處理與附近顯示的 Darwin arm 處理進行比較。驗證 issue 中所述的 shared 和 static configure 組合,確認 framework 建置保持不變,並檢查 static 建置是否成功產生 libpython3.16.a。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
build-system, mobile-dev
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。