gh-96398: Improve accuracy of compiler checks in configure.ac (#117815)

The following variables are now used in compiler checks:
- $ac_cv_gcc_compat is set to 'yes' for GCC compatible compilers
  (the C preprocessor defines the __GNUC__ macro)
- for compiler basename checks, use $CC_BASENAME
  (may contain platform triplets)
- for the rest, use $ac_cv_cc_name
  (does not contain platform triplets)
This commit is contained in:
Erlend E. Aasland 2024-11-07 10:49:58 +01:00 committed by GitHub
parent 75f7cf91ec
commit a5b94d0660
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 127 additions and 203 deletions

135
configure generated vendored
View file

@ -6193,6 +6193,8 @@ printf "%s\n" "$ac_cv_path_EGREP" >&6; }
CC_BASENAME=$(expr "//$CC" : '.*/\(.*\)')
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CC compiler name" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CC compiler name" >&5
printf %s "checking for CC compiler name... " >&6; } printf %s "checking for CC compiler name... " >&6; }
if test ${ac_cv_cc_name+y} if test ${ac_cv_cc_name+y}
@ -6220,8 +6222,9 @@ EOF
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
ac_cv_cc_name=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '` ac_cv_cc_name=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
if test $(expr "//$CC" : '.*/\(.*\)') = "mpicc"; then if test "x$CC_BASENAME" = xmpicc
ac_cv_cc_name="mpicc" then :
ac_cv_cc_name=mpicc
fi fi
else else
ac_cv_cc_name="unknown" ac_cv_cc_name="unknown"
@ -6440,7 +6443,7 @@ printf "%s\n" "$ac_cv_gcc_compat" >&6; }
preset_cxx="$CXX" preset_cxx="$CXX"
if test -z "$CXX" if test -z "$CXX"
then then
case "$CC" in case "$ac_cv_cc_name" in
gcc) if test -n "$ac_tool_prefix"; then gcc) if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
set dummy ${ac_tool_prefix}g++; ac_word=$2 set dummy ${ac_tool_prefix}g++; ac_word=$2
@ -6657,7 +6660,7 @@ else
CXX="$ac_cv_path_CXX" CXX="$ac_cv_path_CXX"
fi fi
;; ;;
clang|*/clang) if test -n "$ac_tool_prefix"; then clang) if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}clang++", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}clang++", so it can be a program name with args.
set dummy ${ac_tool_prefix}clang++; ac_word=$2 set dummy ${ac_tool_prefix}clang++; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@ -6765,7 +6768,7 @@ else
CXX="$ac_cv_path_CXX" CXX="$ac_cv_path_CXX"
fi fi
;; ;;
icc|*/icc) if test -n "$ac_tool_prefix"; then icc) if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}icpc", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}icpc", so it can be a program name with args.
set dummy ${ac_tool_prefix}icpc; ac_word=$2 set dummy ${ac_tool_prefix}icpc; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@ -7374,7 +7377,7 @@ rmdir CaseSensitiveTestDir
case $ac_sys_system in case $ac_sys_system in
hp*|HP*) hp*|HP*)
case $CC in case $ac_cv_cc_name in
cc|*/cc) CC="$CC -Ae";; cc|*/cc) CC="$CC -Ae";;
esac;; esac;;
esac esac
@ -7467,7 +7470,7 @@ printf "%s\n" "$EXPORTSYMS" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
printf %s "checking for GNU ld... " >&6; } printf %s "checking for GNU ld... " >&6; }
ac_prog=ld ac_prog=ld
if test "$GCC" = yes; then if test "$ac_cv_cc_name" = "gcc"; then
ac_prog=`$CC -print-prog-name=ld` ac_prog=`$CC -print-prog-name=ld`
fi fi
case `"$ac_prog" -V 2>&1 < /dev/null` in case `"$ac_prog" -V 2>&1 < /dev/null` in
@ -8338,8 +8341,9 @@ if test "$Py_OPT" = 'true' ; then
DEF_MAKE_ALL_RULE="profile-opt" DEF_MAKE_ALL_RULE="profile-opt"
REQUIRE_PGO="yes" REQUIRE_PGO="yes"
DEF_MAKE_RULE="build_all" DEF_MAKE_RULE="build_all"
case $CC in if test "x$ac_cv_gcc_compat" = xyes
*gcc*) then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fno-semantic-interposition" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fno-semantic-interposition" >&5
printf %s "checking whether C compiler accepts -fno-semantic-interposition... " >&6; } printf %s "checking whether C compiler accepts -fno-semantic-interposition... " >&6; }
if test ${ax_cv_check_cflags__Werror__fno_semantic_interposition+y} if test ${ax_cv_check_cflags__Werror__fno_semantic_interposition+y}
@ -8381,8 +8385,8 @@ else $as_nop
: :
fi fi
;;
esac fi
elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then
DEF_MAKE_ALL_RULE="build_wasm" DEF_MAKE_ALL_RULE="build_wasm"
REQUIRE_PGO="no" REQUIRE_PGO="no"
@ -8409,7 +8413,7 @@ printf "%s\n" "$PROFILE_TASK" >&6; }
llvm_bin_dir='' llvm_bin_dir=''
llvm_path="${PATH}" llvm_path="${PATH}"
if test "${CC}" = "clang" if test "${ac_cv_cc_name}" = "clang"
then then
clang_bin=`which clang` clang_bin=`which clang`
# Some systems install clang elsewhere as a symlink to the real path # Some systems install clang elsewhere as a symlink to the real path
@ -8467,8 +8471,8 @@ printf "%s\n" "no" >&6; }
fi fi
if test "$Py_LTO" = 'true' ; then if test "$Py_LTO" = 'true' ; then
case $CC in case $ac_cv_cc_name in
*clang*) clang)
LDFLAGS_NOLTO="-fno-lto" LDFLAGS_NOLTO="-fno-lto"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -flto=thin" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -flto=thin" >&5
printf %s "checking whether C compiler accepts -flto=thin... " >&6; } printf %s "checking whether C compiler accepts -flto=thin... " >&6; }
@ -8748,14 +8752,14 @@ fi
;; ;;
esac esac
;; ;;
*emcc*) emcc)
if test "$Py_LTO_POLICY" != "default"; then if test "$Py_LTO_POLICY" != "default"; then
as_fn_error $? "emcc supports only default lto." "$LINENO" 5 as_fn_error $? "emcc supports only default lto." "$LINENO" 5
fi fi
LTOFLAGS="-flto" LTOFLAGS="-flto"
LTOCFLAGS="-flto" LTOCFLAGS="-flto"
;; ;;
*gcc*) gcc)
if test $Py_LTO_POLICY = thin if test $Py_LTO_POLICY = thin
then then
as_fn_error $? "thin lto is not supported under gcc compiler." "$LINENO" 5 as_fn_error $? "thin lto is not supported under gcc compiler." "$LINENO" 5
@ -8921,10 +8925,8 @@ printf "%s\n" "$as_me: llvm-profdata found via xcrun: ${LLVM_PROFDATA}" >&6;}
fi fi
LLVM_PROF_ERR=no LLVM_PROF_ERR=no
# GNU Autoconf recommends the use of expr instead of basename. case "$ac_cv_cc_name" in
CC_BASENAME=$(expr "//$CC" : '.*/\(.*\)') clang)
case "$CC_BASENAME" in
*clang*)
# Any changes made here should be reflected in the GCC+Darwin case below # Any changes made here should be reflected in the GCC+Darwin case below
PGO_PROF_GEN_FLAG="-fprofile-instr-generate" PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\"" PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
@ -8939,31 +8941,13 @@ case "$CC_BASENAME" in
fi fi
fi fi
;; ;;
*gcc*) gcc)
case $ac_sys_system in
Darwin*)
PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
LLVM_PROF_MERGER=" ${LLVM_PROFDATA} merge -output=\"\$(shell pwd)/code.profclangd\" \"\$(shell pwd)\"/*.profclangr "
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
if test "${LLVM_PROF_FOUND}" = "not-found"
then
LLVM_PROF_ERR=yes
if test "${REQUIRE_PGO}" = "yes"
then
as_fn_error $? "llvm-profdata is required for a --enable-optimizations build but could not be found." "$LINENO" 5
fi
fi
;;
*)
PGO_PROF_GEN_FLAG="-fprofile-generate" PGO_PROF_GEN_FLAG="-fprofile-generate"
PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction" PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
LLVM_PROF_MERGER="true" LLVM_PROF_MERGER="true"
LLVM_PROF_FILE="" LLVM_PROF_FILE=""
;; ;;
esac icc)
;;
*icc*)
PGO_PROF_GEN_FLAG="-prof-gen" PGO_PROF_GEN_FLAG="-prof-gen"
PGO_PROF_USE_FLAG="-prof-use" PGO_PROF_USE_FLAG="-prof-use"
LLVM_PROF_MERGER="true" LLVM_PROF_MERGER="true"
@ -9329,19 +9313,6 @@ printf "%s\n" "$BOLT_APPLY_FLAGS" >&6; }
# compiler and platform. BASECFLAGS tweaks need to be made even if the # compiler and platform. BASECFLAGS tweaks need to be made even if the
# user set OPT. # user set OPT.
case $CC in
*clang*)
cc_is_clang=1
;;
*)
if $CC --version 2>&1 | grep -q clang
then
cc_is_clang=1
else
cc_is_clang=
fi
esac
save_CFLAGS=$CFLAGS save_CFLAGS=$CFLAGS
CFLAGS="-fstrict-overflow -fno-strict-overflow" CFLAGS="-fstrict-overflow -fno-strict-overflow"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports -fstrict-overflow and -fno-strict-overflow" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports -fstrict-overflow and -fno-strict-overflow" >&5
@ -9465,7 +9436,7 @@ if test "${OPT-unset}" = "unset"
then then
case $GCC in case $GCC in
yes) yes)
if test -n "${cc_is_clang}" if test "${ac_cv_cc_name}" != "clang"
then then
# bpo-30104: disable strict aliasing to compile correctly dtoa.c, # bpo-30104: disable strict aliasing to compile correctly dtoa.c,
# see Makefile.pre.in for more information # see Makefile.pre.in for more information
@ -9964,8 +9935,9 @@ fi
fi fi
case $GCC in if test "x$ac_cv_gcc_compat" = xyes
yes) then :
CFLAGS_NODIST="$CFLAGS_NODIST -std=c11" CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
@ -10083,8 +10055,8 @@ fi
# ICC doesn't recognize the option, but only emits a warning # ICC doesn't recognize the option, but only emits a warning
## XXX does it emit an unused result warning and can it be disabled? ## XXX does it emit an unused result warning and can it be disabled?
case "$CC_BASENAME" in #( case "$ac_cv_cc_name" in #(
*icc*) : icc) :
ac_cv_disable_unused_result_warning=no ac_cv_disable_unused_result_warning=no
@ -10489,8 +10461,6 @@ fi
Darwin*) Darwin*)
# -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
# used to be here, but non-Apple gcc doesn't accept them. # used to be here, but non-Apple gcc doesn't accept them.
if test "${CC}" = gcc
then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which compiler should be used" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which compiler should be used" >&5
printf %s "checking which compiler should be used... " >&6; } printf %s "checking which compiler should be used... " >&6; }
case "${UNIVERSALSDK}" in case "${UNIVERSALSDK}" in
@ -10504,7 +10474,6 @@ printf %s "checking which compiler should be used... " >&6; }
esac esac
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
printf "%s\n" "$CC" >&6; } printf "%s\n" "$CC" >&6; }
fi
LIPO_INTEL64_FLAGS="" LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}" if test "${enable_universalsdk}"
@ -10650,9 +10619,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \
# end of Darwin* tests # end of Darwin* tests
;; ;;
esac esac
;;
*) else $as_nop
case $ac_sys_system in case $ac_sys_system in
OpenUNIX*|UnixWare*) OpenUNIX*|UnixWare*)
BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
@ -10661,18 +10630,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \
BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
;; ;;
esac esac
;;
esac
case "$CC_BASENAME" in fi
*mpicc*)
case "$ac_cv_cc_name" in
mpicc)
CFLAGS_NODIST="$CFLAGS_NODIST" CFLAGS_NODIST="$CFLAGS_NODIST"
;; ;;
*icc*) icc)
# ICC needs -fp-model strict or floats behave badly # ICC needs -fp-model strict or floats behave badly
CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict"
;; ;;
*xlc*) xlc)
CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1" CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1"
;; ;;
esac esac
@ -13195,7 +13164,7 @@ then
LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp" LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp"
;; ;;
SunOS/5*) SunOS/5*)
if test "$GCC" = "yes" ; then if test "$ac_cv_gcc_compat" = "yes" ; then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared' LDCXXSHARED='$(CXX) -shared'
else else
@ -13203,7 +13172,7 @@ then
LDCXXSHARED='$(CXX) -G' LDCXXSHARED='$(CXX) -G'
fi ;; fi ;;
hp*|HP*) hp*|HP*)
if test "$GCC" = "yes" ; then if test "$ac_cv_gcc_compat" = "yes" ; then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared' LDCXXSHARED='$(CXX) -shared'
else else
@ -13296,7 +13265,7 @@ then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';; LDCXXSHARED='$(CXX) -shared';;
OpenUNIX*|UnixWare*) OpenUNIX*|UnixWare*)
if test "$GCC" = "yes" ; then if test "$ac_cv_gcc_compat" = "yes" ; then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared' LDCXXSHARED='$(CXX) -shared'
else else
@ -13340,13 +13309,13 @@ printf %s "checking CCSHARED... " >&6; }
if test -z "$CCSHARED" if test -z "$CCSHARED"
then then
case $ac_sys_system/$ac_sys_release in case $ac_sys_system/$ac_sys_release in
SunOS*) if test "$GCC" = yes; SunOS*) if test "$ac_cv_gcc_compat" = "yes";
then CCSHARED="-fPIC"; then CCSHARED="-fPIC";
elif test `uname -p` = sparc; elif test `uname -p` = sparc;
then CCSHARED="-xcode=pic32"; then CCSHARED="-xcode=pic32";
else CCSHARED="-Kpic"; else CCSHARED="-Kpic";
fi;; fi;;
hp*|HP*) if test "$GCC" = yes; hp*|HP*) if test "$ac_cv_gcc_compat" = "yes";
then CCSHARED="-fPIC"; then CCSHARED="-fPIC";
else CCSHARED="+z"; else CCSHARED="+z";
fi;; fi;;
@ -13361,12 +13330,12 @@ fi;;
FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Haiku*) CCSHARED="-fPIC";; Haiku*) CCSHARED="-fPIC";;
OpenUNIX*|UnixWare*) OpenUNIX*|UnixWare*)
if test "$GCC" = "yes" if test "$ac_cv_gcc_compat" = "yes"
then CCSHARED="-fPIC" then CCSHARED="-fPIC"
else CCSHARED="-KPIC" else CCSHARED="-KPIC"
fi;; fi;;
SCO_SV*) SCO_SV*)
if test "$GCC" = "yes" if test "$ac_cv_gcc_compat" = "yes"
then CCSHARED="-fPIC" then CCSHARED="-fPIC"
else CCSHARED="-Kpic -belf" else CCSHARED="-Kpic -belf"
fi;; fi;;
@ -13426,13 +13395,13 @@ printf "%s\n" "#define THREAD_STACK_SIZE 0x$stack_size" >>confdefs.h
then then
LINKFORSHARED="-Wl,--export-dynamic" LINKFORSHARED="-Wl,--export-dynamic"
fi;; fi;;
SunOS/5*) case $CC in SunOS/5*) if test "$ac_cv_gcc_compat" = "yes"; then
*gcc*)
if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
then then
LINKFORSHARED="-Xlinker --export-dynamic" LINKFORSHARED="-Xlinker --export-dynamic"
fi;; fi
esac;; fi
;;
CYGWIN*) CYGWIN*)
if test $enable_shared = "no" if test $enable_shared = "no"
then then
@ -15323,7 +15292,7 @@ esac
fi fi
elif test $ac_cv_sizeof_size_t -eq 4; then elif test $ac_cv_sizeof_size_t -eq 4; then
if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then
case $CC in #( case $ac_cv_cc_name in #(
*gcc*) : *gcc*) :
libmpdec_machine=ppro ;; #( libmpdec_machine=ppro ;; #(
*clang*) : *clang*) :
@ -28206,8 +28175,8 @@ if test "$ac_cv_gcc_asm_for_x87" = yes; then
# Some versions of gcc miscompile inline asm: # Some versions of gcc miscompile inline asm:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
# http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
case $CC in case $ac_cv_cc_name in
*gcc*) gcc)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc ipa-pure-const bug" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc ipa-pure-const bug" >&5
printf %s "checking for gcc ipa-pure-const bug... " >&6; } printf %s "checking for gcc ipa-pure-const bug... " >&6; }
saved_cflags="$CFLAGS" saved_cflags="$CFLAGS"

View file

@ -1048,6 +1048,9 @@ AC_PROG_GREP
AC_PROG_SED AC_PROG_SED
AC_PROG_EGREP AC_PROG_EGREP
dnl GNU Autoconf recommends the use of expr instead of basename.
AS_VAR_SET([CC_BASENAME], [$(expr "//$CC" : '.*/\(.*\)')])
dnl detect compiler name dnl detect compiler name
dnl check for xlc before clang, newer xlc's can use clang as frontend. dnl check for xlc before clang, newer xlc's can use clang as frontend.
dnl check for GCC last, other compilers set __GNUC__, too. dnl check for GCC last, other compilers set __GNUC__, too.
@ -1073,9 +1076,7 @@ EOF
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
ac_cv_cc_name=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '` ac_cv_cc_name=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
if test $(expr "//$CC" : '.*/\(.*\)') = "mpicc"; then AS_VAR_IF([CC_BASENAME], [mpicc], [ac_cv_cc_name=mpicc])
ac_cv_cc_name="mpicc"
fi
else else
ac_cv_cc_name="unknown" ac_cv_cc_name="unknown"
fi fi
@ -1104,11 +1105,11 @@ AC_SUBST([CXX])
preset_cxx="$CXX" preset_cxx="$CXX"
if test -z "$CXX" if test -z "$CXX"
then then
case "$CC" in case "$ac_cv_cc_name" in
gcc) AC_PATH_TOOL([CXX], [g++], [g++], [notfound]) ;; gcc) AC_PATH_TOOL([CXX], [g++], [g++], [notfound]) ;;
cc) AC_PATH_TOOL([CXX], [c++], [c++], [notfound]) ;; cc) AC_PATH_TOOL([CXX], [c++], [c++], [notfound]) ;;
clang|*/clang) AC_PATH_TOOL([CXX], [clang++], [clang++], [notfound]) ;; clang) AC_PATH_TOOL([CXX], [clang++], [clang++], [notfound]) ;;
icc|*/icc) AC_PATH_TOOL([CXX], [icpc], [icpc], [notfound]) ;; icc) AC_PATH_TOOL([CXX], [icpc], [icpc], [notfound]) ;;
esac esac
if test "$CXX" = "notfound" if test "$CXX" = "notfound"
then then
@ -1381,7 +1382,7 @@ rmdir CaseSensitiveTestDir
case $ac_sys_system in case $ac_sys_system in
hp*|HP*) hp*|HP*)
case $CC in case $ac_cv_cc_name in
cc|*/cc) CC="$CC -Ae";; cc|*/cc) CC="$CC -Ae";;
esac;; esac;;
esac esac
@ -1467,7 +1468,7 @@ AC_MSG_RESULT([$EXPORTSYMS])
AC_SUBST([GNULD]) AC_SUBST([GNULD])
AC_MSG_CHECKING([for GNU ld]) AC_MSG_CHECKING([for GNU ld])
ac_prog=ld ac_prog=ld
if test "$GCC" = yes; then if test "$ac_cv_cc_name" = "gcc"; then
ac_prog=`$CC -print-prog-name=ld` ac_prog=`$CC -print-prog-name=ld`
fi fi
case `"$ac_prog" -V 2>&1 < /dev/null` in case `"$ac_prog" -V 2>&1 < /dev/null` in
@ -1874,14 +1875,12 @@ if test "$Py_OPT" = 'true' ; then
DEF_MAKE_ALL_RULE="profile-opt" DEF_MAKE_ALL_RULE="profile-opt"
REQUIRE_PGO="yes" REQUIRE_PGO="yes"
DEF_MAKE_RULE="build_all" DEF_MAKE_RULE="build_all"
case $CC in AS_VAR_IF([ac_cv_gcc_compat], [yes], [
*gcc*)
AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[ AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[
CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition" CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition" LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
], [], [-Werror]) ], [], [-Werror])
;; ])
esac
elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then
dnl Emscripten does not support shared extensions yet. Build dnl Emscripten does not support shared extensions yet. Build
dnl "python.[js,wasm]", "pybuilddir.txt", and "platform" files. dnl "python.[js,wasm]", "pybuilddir.txt", and "platform" files.
@ -1908,7 +1907,7 @@ AC_MSG_RESULT([$PROFILE_TASK])
llvm_bin_dir='' llvm_bin_dir=''
llvm_path="${PATH}" llvm_path="${PATH}"
if test "${CC}" = "clang" if test "${ac_cv_cc_name}" = "clang"
then then
clang_bin=`which clang` clang_bin=`which clang`
# Some systems install clang elsewhere as a symlink to the real path # Some systems install clang elsewhere as a symlink to the real path
@ -1955,8 +1954,8 @@ esac
], ],
[AC_MSG_RESULT([no])]) [AC_MSG_RESULT([no])])
if test "$Py_LTO" = 'true' ; then if test "$Py_LTO" = 'true' ; then
case $CC in case $ac_cv_cc_name in
*clang*) clang)
LDFLAGS_NOLTO="-fno-lto" LDFLAGS_NOLTO="-fno-lto"
dnl Clang linker requires -flto in order to link objects with LTO information. dnl Clang linker requires -flto in order to link objects with LTO information.
dnl Thin LTO is faster and works for object files with full LTO information, too. dnl Thin LTO is faster and works for object files with full LTO information, too.
@ -2019,14 +2018,14 @@ if test "$Py_LTO" = 'true' ; then
;; ;;
esac esac
;; ;;
*emcc*) emcc)
if test "$Py_LTO_POLICY" != "default"; then if test "$Py_LTO_POLICY" != "default"; then
AC_MSG_ERROR([emcc supports only default lto.]) AC_MSG_ERROR([emcc supports only default lto.])
fi fi
LTOFLAGS="-flto" LTOFLAGS="-flto"
LTOCFLAGS="-flto" LTOCFLAGS="-flto"
;; ;;
*gcc*) gcc)
if test $Py_LTO_POLICY = thin if test $Py_LTO_POLICY = thin
then then
AC_MSG_ERROR([thin lto is not supported under gcc compiler.]) AC_MSG_ERROR([thin lto is not supported under gcc compiler.])
@ -2085,10 +2084,8 @@ then
fi fi
LLVM_PROF_ERR=no LLVM_PROF_ERR=no
# GNU Autoconf recommends the use of expr instead of basename. case "$ac_cv_cc_name" in
AS_VAR_SET([CC_BASENAME], [$(expr "//$CC" : '.*/\(.*\)')]) clang)
case "$CC_BASENAME" in
*clang*)
# Any changes made here should be reflected in the GCC+Darwin case below # Any changes made here should be reflected in the GCC+Darwin case below
PGO_PROF_GEN_FLAG="-fprofile-instr-generate" PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\"" PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
@ -2107,35 +2104,13 @@ case "$CC_BASENAME" in
fi fi
fi fi
;; ;;
*gcc*) gcc)
case $ac_sys_system in
Darwin*)
PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
LLVM_PROF_MERGER=m4_normalize("
${LLVM_PROFDATA} merge
-output=\"\$(shell pwd)/code.profclangd\"
\"\$(shell pwd)\"/*.profclangr
")
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
if test "${LLVM_PROF_FOUND}" = "not-found"
then
LLVM_PROF_ERR=yes
if test "${REQUIRE_PGO}" = "yes"
then
AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
fi
fi
;;
*)
PGO_PROF_GEN_FLAG="-fprofile-generate" PGO_PROF_GEN_FLAG="-fprofile-generate"
PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction" PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
LLVM_PROF_MERGER="true" LLVM_PROF_MERGER="true"
LLVM_PROF_FILE="" LLVM_PROF_FILE=""
;; ;;
esac icc)
;;
*icc*)
PGO_PROF_GEN_FLAG="-prof-gen" PGO_PROF_GEN_FLAG="-prof-gen"
PGO_PROF_USE_FLAG="-prof-use" PGO_PROF_USE_FLAG="-prof-use"
LLVM_PROF_MERGER="true" LLVM_PROF_MERGER="true"
@ -2259,19 +2234,6 @@ AC_MSG_RESULT([$BOLT_APPLY_FLAGS])
# compiler and platform. BASECFLAGS tweaks need to be made even if the # compiler and platform. BASECFLAGS tweaks need to be made even if the
# user set OPT. # user set OPT.
case $CC in
*clang*)
cc_is_clang=1
;;
*)
if $CC --version 2>&1 | grep -q clang
then
cc_is_clang=1
else
cc_is_clang=
fi
esac
dnl Historically, some of our code assumed that signed integer overflow dnl Historically, some of our code assumed that signed integer overflow
dnl is defined behaviour via twos-complement. dnl is defined behaviour via twos-complement.
dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support. dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support.
@ -2346,7 +2308,7 @@ if test "${OPT-unset}" = "unset"
then then
case $GCC in case $GCC in
yes) yes)
if test -n "${cc_is_clang}" if test "${ac_cv_cc_name}" != "clang"
then then
# bpo-30104: disable strict aliasing to compile correctly dtoa.c, # bpo-30104: disable strict aliasing to compile correctly dtoa.c,
# see Makefile.pre.in for more information # see Makefile.pre.in for more information
@ -2526,8 +2488,7 @@ then
AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=3], [CFLAGS_NODIST="$CFLAGS_NODIST -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"], [AC_MSG_WARN([-D_FORTIFY_SOURCE=3 not supported])], [-Werror]) AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=3], [CFLAGS_NODIST="$CFLAGS_NODIST -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"], [AC_MSG_WARN([-D_FORTIFY_SOURCE=3 not supported])], [-Werror])
fi fi
case $GCC in AS_VAR_IF([ac_cv_gcc_compat], [yes], [
yes)
CFLAGS_NODIST="$CFLAGS_NODIST -std=c11" CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
PY_CHECK_CC_WARNING([enable], [extra], [if we can add -Wextra]) PY_CHECK_CC_WARNING([enable], [extra], [if we can add -Wextra])
@ -2568,8 +2529,8 @@ yes)
# ICC doesn't recognize the option, but only emits a warning # ICC doesn't recognize the option, but only emits a warning
## XXX does it emit an unused result warning and can it be disabled? ## XXX does it emit an unused result warning and can it be disabled?
AS_CASE(["$CC_BASENAME"], AS_CASE(["$ac_cv_cc_name"],
[*icc*], [ac_cv_disable_unused_result_warning=no] [icc], [ac_cv_disable_unused_result_warning=no]
[PY_CHECK_CC_WARNING([disable], [unused-result])]) [PY_CHECK_CC_WARNING([disable], [unused-result])])
AS_VAR_IF([ac_cv_disable_unused_result_warning], [yes], AS_VAR_IF([ac_cv_disable_unused_result_warning], [yes],
[BASECFLAGS="$BASECFLAGS -Wno-unused-result" [BASECFLAGS="$BASECFLAGS -Wno-unused-result"
@ -2662,8 +2623,6 @@ yes)
Darwin*) Darwin*)
# -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
# used to be here, but non-Apple gcc doesn't accept them. # used to be here, but non-Apple gcc doesn't accept them.
if test "${CC}" = gcc
then
AC_MSG_CHECKING([which compiler should be used]) AC_MSG_CHECKING([which compiler should be used])
case "${UNIVERSALSDK}" in case "${UNIVERSALSDK}" in
*/MacOSX10.4u.sdk) */MacOSX10.4u.sdk)
@ -2675,7 +2634,6 @@ yes)
;; ;;
esac esac
AC_MSG_RESULT([$CC]) AC_MSG_RESULT([$CC])
fi
LIPO_INTEL64_FLAGS="" LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}" if test "${enable_universalsdk}"
@ -2800,9 +2758,7 @@ yes)
# end of Darwin* tests # end of Darwin* tests
;; ;;
esac esac
;; ], [
*)
case $ac_sys_system in case $ac_sys_system in
OpenUNIX*|UnixWare*) OpenUNIX*|UnixWare*)
BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
@ -2811,18 +2767,17 @@ yes)
BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
;; ;;
esac esac
;; ])
esac
case "$CC_BASENAME" in case "$ac_cv_cc_name" in
*mpicc*) mpicc)
CFLAGS_NODIST="$CFLAGS_NODIST" CFLAGS_NODIST="$CFLAGS_NODIST"
;; ;;
*icc*) icc)
# ICC needs -fp-model strict or floats behave badly # ICC needs -fp-model strict or floats behave badly
CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict"
;; ;;
*xlc*) xlc)
CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1" CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1"
;; ;;
esac esac
@ -3430,7 +3385,7 @@ then
LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp" LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp"
;; ;;
SunOS/5*) SunOS/5*)
if test "$GCC" = "yes" ; then if test "$ac_cv_gcc_compat" = "yes" ; then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared' LDCXXSHARED='$(CXX) -shared'
else else
@ -3438,7 +3393,7 @@ then
LDCXXSHARED='$(CXX) -G' LDCXXSHARED='$(CXX) -G'
fi ;; fi ;;
hp*|HP*) hp*|HP*)
if test "$GCC" = "yes" ; then if test "$ac_cv_gcc_compat" = "yes" ; then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared' LDCXXSHARED='$(CXX) -shared'
else else
@ -3531,7 +3486,7 @@ then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';; LDCXXSHARED='$(CXX) -shared';;
OpenUNIX*|UnixWare*) OpenUNIX*|UnixWare*)
if test "$GCC" = "yes" ; then if test "$ac_cv_gcc_compat" = "yes" ; then
LDSHARED='$(CC) -shared' LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared' LDCXXSHARED='$(CXX) -shared'
else else
@ -3571,13 +3526,13 @@ AC_MSG_CHECKING([CCSHARED])
if test -z "$CCSHARED" if test -z "$CCSHARED"
then then
case $ac_sys_system/$ac_sys_release in case $ac_sys_system/$ac_sys_release in
SunOS*) if test "$GCC" = yes; SunOS*) if test "$ac_cv_gcc_compat" = "yes";
then CCSHARED="-fPIC"; then CCSHARED="-fPIC";
elif test `uname -p` = sparc; elif test `uname -p` = sparc;
then CCSHARED="-xcode=pic32"; then CCSHARED="-xcode=pic32";
else CCSHARED="-Kpic"; else CCSHARED="-Kpic";
fi;; fi;;
hp*|HP*) if test "$GCC" = yes; hp*|HP*) if test "$ac_cv_gcc_compat" = "yes";
then CCSHARED="-fPIC"; then CCSHARED="-fPIC";
else CCSHARED="+z"; else CCSHARED="+z";
fi;; fi;;
@ -3589,12 +3544,12 @@ then
FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Haiku*) CCSHARED="-fPIC";; Haiku*) CCSHARED="-fPIC";;
OpenUNIX*|UnixWare*) OpenUNIX*|UnixWare*)
if test "$GCC" = "yes" if test "$ac_cv_gcc_compat" = "yes"
then CCSHARED="-fPIC" then CCSHARED="-fPIC"
else CCSHARED="-KPIC" else CCSHARED="-KPIC"
fi;; fi;;
SCO_SV*) SCO_SV*)
if test "$GCC" = "yes" if test "$ac_cv_gcc_compat" = "yes"
then CCSHARED="-fPIC" then CCSHARED="-fPIC"
else CCSHARED="-Kpic -belf" else CCSHARED="-Kpic -belf"
fi;; fi;;
@ -3652,13 +3607,13 @@ then
then then
LINKFORSHARED="-Wl,--export-dynamic" LINKFORSHARED="-Wl,--export-dynamic"
fi;; fi;;
SunOS/5*) case $CC in SunOS/5*) if test "$ac_cv_gcc_compat" = "yes"; then
*gcc*)
if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
then then
LINKFORSHARED="-Xlinker --export-dynamic" LINKFORSHARED="-Xlinker --export-dynamic"
fi;; fi
esac;; fi
;;
CYGWIN*) CYGWIN*)
if test $enable_shared = "no" if test $enable_shared = "no"
then then
@ -4228,7 +4183,7 @@ AS_VAR_IF(
fi fi
elif test $ac_cv_sizeof_size_t -eq 4; then elif test $ac_cv_sizeof_size_t -eq 4; then
if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then
AS_CASE([$CC], AS_CASE([$ac_cv_cc_name],
[*gcc*], [libmpdec_machine=ppro], [*gcc*], [libmpdec_machine=ppro],
[*clang*], [libmpdec_machine=ppro], [*clang*], [libmpdec_machine=ppro],
[libmpdec_machine=ansi32] [libmpdec_machine=ansi32]
@ -7150,8 +7105,8 @@ if test "$ac_cv_gcc_asm_for_x87" = yes; then
# Some versions of gcc miscompile inline asm: # Some versions of gcc miscompile inline asm:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
# http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
case $CC in case $ac_cv_cc_name in
*gcc*) gcc)
AC_MSG_CHECKING([for gcc ipa-pure-const bug]) AC_MSG_CHECKING([for gcc ipa-pure-const bug])
saved_cflags="$CFLAGS" saved_cflags="$CFLAGS"
CFLAGS="-O2" CFLAGS="-O2"