python / python/cpython

macOS: configure does not support linking against a non-system libffi

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

還沒有人認領這個 Issue。

build OS-mac type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

On macOS, the configure script does not provide a way to link _ctypes against a non-system libffi.

Although LIBFFI_CFLAGS and LIBFFI_LIBS are documented as configuration variables for libffi, configure first checks for the system libffi from Apple's SDK and if found overwrites these variables.
The pkg-config based check, which does preserve these variables, is never run when the system libffi is detected.

The confusing --with-system-ffi option, removed in Python 3.12 (#100544), provided a way to invoke the pkg-config based configuration on macOS, bypassing the detection of the SDK libffi.

I ran into this while updating python-build-standalone to use the standard extension configuration in 3.12+ (astral-sh/python-build-standalone#1180). Other than patching configure the best option seemed to be to use ac_cv_lib_ffi_ffi_call=no to force the check to fail.

I also found that conda-forge patches configure to get around this issue when building CPython.

Related issues
CPython versions tested on:

3.12, 3.13, 3.14, 3.15, CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-156486

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

從第 4363–4392 行附近連結的 configure.ac 檢查開始,並將其與產生的 configure 指令碼進行比較。追蹤 LIBFFI_CFLAGS、LIBFFI_LIBS、macOS SDK libffi 檢查和 pkg-config 檢查之間如何互動。完成的標準是 macOS 建置能夠保留使用者提供的設定,並將 _ctypes 連結到非系統 libffi。

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

評估

技術堆疊
python
領域
build-system
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

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

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