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

Đang mở
#96,249 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
shell
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu trong configure.ac quanh các dòng 1491–1514 và tái hiện bằng CC='/opt/local/bin/gcc-mp-12' pyenv install --verbose 3.10.6 trên macOS. So sánh việc nhận dạng trình biên dịch với các flag Darwin PGO được chọn ở đó. Hoàn tất có nghĩa là GCC thực sự sử dụng -fprofile-generate, trong khi Apple Clang tiếp tục sử dụng các flag hiện có, mà không làm hỏng đường dẫn configure.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
558

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.