Skip to content

Commit 0515eaf

Browse files
authored
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.
1 parent b9ebde8 commit 0515eaf

File tree

3 files changed

+71
-14
lines changed

3 files changed

+71
-14
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix the test checking if the C compiler supports ``-Og`` option in the
2+
``./configure`` script to also use ``-Og`` on clang which supports it. Patch
3+
by Victor Stinner.

configure

Lines changed: 45 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,28 @@ case $CC in
17911791
fi
17921792
esac
17931793

1794+
# Check if CC supports -Og optimization level
1795+
_SAVE_VAR([CFLAGS])
1796+
CFLAGS="-Og"
1797+
AC_CACHE_CHECK([if $CC supports -Og optimization level],
1798+
[ac_cv_cc_supports_og],
1799+
AC_COMPILE_IFELSE(
1800+
[
1801+
AC_LANG_PROGRAM([[]], [[]])
1802+
],[
1803+
ac_cv_cc_supports_og=yes
1804+
],[
1805+
ac_cv_cc_supports_og=no
1806+
])
1807+
)
1808+
_RESTORE_VAR([CFLAGS])
1809+
1810+
# Optimization messes up debuggers, so turn it off for
1811+
# debug builds.
1812+
PYDEBUG_CFLAGS="-O0"
1813+
AS_VAR_IF([ac_cv_cc_supports_og], [yes],
1814+
[PYDEBUG_CFLAGS="-Og"])
1815+
17941816
# tweak OPT based on compiler and platform, only if the user didn't set
17951817
# it on the command line
17961818
AC_SUBST(OPT)
@@ -1816,13 +1838,7 @@ then
18161838
case $ac_cv_prog_cc_g in
18171839
yes)
18181840
if test "$Py_DEBUG" = 'true' ; then
1819-
# Optimization messes up debuggers, so turn it off for
1820-
# debug builds.
1821-
if "$CC" -v --help 2>/dev/null |grep -- -Og > /dev/null; then
1822-
OPT="-g -Og -Wall"
1823-
else
1824-
OPT="-g -O0 -Wall"
1825-
fi
1841+
OPT="-g $PYDEBUG_CFLAGS -Wall"
18261842
else
18271843
OPT="-g $WRAP -O3 -Wall"
18281844
fi

0 commit comments

Comments
 (0)