summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-02-01 13:47:12 (GMT)
committerGitHub <noreply@github.com>2022-02-01 13:47:12 (GMT)
commit0515eafe55ce7699e3bbc3c1555f08073d43b790 (patch)
treeb649b51226c6403f8436e7dab3fd521c83f9b455 /configure.ac
parentb9ebde8db7e176e021103745cd012bae700828b5 (diff)
downloadcpython-0515eafe55ce7699e3bbc3c1555f08073d43b790.zip
cpython-0515eafe55ce7699e3bbc3c1555f08073d43b790.tar.gz
cpython-0515eafe55ce7699e3bbc3c1555f08073d43b790.tar.bz2
bpo-46600: ./configure --with-pydebug uses -Og with clang (GH-31052)
Fix the test checking if the C compiler supports -Og option in the ./configure script to also use -Og on clang which supports it.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac30
1 files changed, 23 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 5a07664..6204747 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1791,6 +1791,28 @@ case $CC in
fi
esac
+# Check if CC supports -Og optimization level
+_SAVE_VAR([CFLAGS])
+CFLAGS="-Og"
+AC_CACHE_CHECK([if $CC supports -Og optimization level],
+ [ac_cv_cc_supports_og],
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM([[]], [[]])
+ ],[
+ ac_cv_cc_supports_og=yes
+ ],[
+ ac_cv_cc_supports_og=no
+ ])
+)
+_RESTORE_VAR([CFLAGS])
+
+# Optimization messes up debuggers, so turn it off for
+# debug builds.
+PYDEBUG_CFLAGS="-O0"
+AS_VAR_IF([ac_cv_cc_supports_og], [yes],
+ [PYDEBUG_CFLAGS="-Og"])
+
# tweak OPT based on compiler and platform, only if the user didn't set
# it on the command line
AC_SUBST(OPT)
@@ -1816,13 +1838,7 @@ then
case $ac_cv_prog_cc_g in
yes)
if test "$Py_DEBUG" = 'true' ; then
- # Optimization messes up debuggers, so turn it off for
- # debug builds.
- if "$CC" -v --help 2>/dev/null |grep -- -Og > /dev/null; then
- OPT="-g -Og -Wall"
- else
- OPT="-g -O0 -Wall"
- fi
+ OPT="-g $PYDEBUG_CFLAGS -Wall"
else
OPT="-g $WRAP -O3 -Wall"
fi