Open
Description
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:
- Check for the presence of
Apple clang
in the$CC --version
output. - Check that the absolute path of
$CC
is/usr/bin/gcc
.