On macOS, Configure script assumes that "gcc" is an alias for "clang", even if it really is GCC

未關閉
#96,249 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

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

研究方向

從 configure.ac 的 1491–1514 行附近開始,並在 macOS 上使用 CC='/opt/local/bin/gcc-mp-12' pyenv install --verbose 3.10.6 重現問題。將編譯器識別結果與那裡選取的 Darwin PGO flags 進行比較。完成的標準是實際的 GCC 使用 -fprofile-generate,而 Apple Clang 繼續使用現有 flags,且不破壞 configure 路徑。

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

描述

build type-bug

Your environment

  • MacOS 12.4

Bug report

Apologies if this is a known "wontfix" issue, I didn't see it mentioned in a search of past issues.

The configure.ac script assumes that gcc is actually clang on MacOS and uses Clang's -fprofile-instr-generate flag for PGO instead of GCC's -fprofile-generate, leading to build failure when PGO is turned on.

Steps to reproduce on MacOS:

sudo port install gcc
# or `brew install gcc`, same result

CC='/opt/local/bin/gcc-mp-12' pyenv install --verbose 3.10.6

Outcome:

...
gcc-mp-12: error: unrecognized command-line option '-fprofile-instr-generate'; did you mean '-fprofile-generate'?
...

The problem is found here: https://github.com/python/cpython/blob/3.10/configure.ac#L1491-L1514

case $CC in
  *clang*)
    # Any changes made here should be reflected in the GCC+Darwin case below
    ...
    ;;
  *gcc*)
    case $ac_sys_system in
      Darwin*)
        PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
        PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"

MacOS (perhaps annoyingly) ships with gcc as an alias for clang, so the configure script sensibly assumes that gcc is actually clang and sets its options accordingly.

However, that isn't always a correct assumption!

Possible solutions:

  1. Check for the presence of Apple clang in the $CC --version output.
  2. Check that the absolute path of $CC is /usr/bin/gcc.
主要語言
Python
星號
77.2k
分支
36k
平均合併
1 天 9 小時
30 天內合併 PR
558

貢獻指南

開啟貢獻指南

從這裡開始

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

python/cpython 的其他 Issue

查看 python/cpython 的全部 Issue

相似的 Issue

更多 Python Issue

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

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