Skip to content

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

Open
@gwerbin

Description

@gwerbin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions