From 4a196c4ad6ed2b07e2cc7162e60481942936b4cc Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Tue, 19 Aug 2025 21:01:00 -0400 Subject: [PATCH 1/6] gh-128042: `configure` complains when CFLAGS=-O0 and --enable-optimizations are set --- configure | 6 ++++++ configure.ac | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/configure b/configure index 568db406dbc67b..7027c2e6326e5f 100755 --- a/configure +++ b/configure @@ -8407,6 +8407,12 @@ fi if test "$Py_OPT" = 'true' ; then + # Check for conflicting CFLAGS=-O0 and --enable-optimizations + case "$CFLAGS" in + *-O0*) + as_fn_error $? "CFLAGS contains -O0 which conflicts with --enable-optimizations. Please remove -O0 from CFLAGS or do not use --enable-optimizations." "$LINENO" 5 + ;; + esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not # compile working code using it and both test_distutils and test_gdb are # broken when you do manage to get a toolchain that works with it. People diff --git a/configure.ac b/configure.ac index bbaff7f80352b8..07428e2d11b26b 100644 --- a/configure.ac +++ b/configure.ac @@ -1823,6 +1823,12 @@ fi], [AC_MSG_RESULT([no])]) if test "$Py_OPT" = 'true' ; then + # Check for conflicting CFLAGS=-O0 and --enable-optimizations + case "$CFLAGS" in + *-O0*) + AC_MSG_ERROR([CFLAGS contains -O0 which conflicts with --enable-optimizations. Please remove -O0 from CFLAGS or do not use --enable-optimizations.]) + ;; + esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not # compile working code using it and both test_distutils and test_gdb are # broken when you do manage to get a toolchain that works with it. People From f8d75ce44bfa718668159d89c729ac432537d315 Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Wed, 20 Aug 2025 09:47:56 -0400 Subject: [PATCH 2/6] Warn instead of error --- configure | 3 ++- configure.ac | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 7027c2e6326e5f..bdeab8a6d126a3 100755 --- a/configure +++ b/configure @@ -8410,7 +8410,8 @@ if test "$Py_OPT" = 'true' ; then # Check for conflicting CFLAGS=-O0 and --enable-optimizations case "$CFLAGS" in *-O0*) - as_fn_error $? "CFLAGS contains -O0 which conflicts with --enable-optimizations. Please remove -O0 from CFLAGS or do not use --enable-optimizations." "$LINENO" 5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance." >&5 +printf "%s\n" "$as_me: WARNING: CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance." >&2;} ;; esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not diff --git a/configure.ac b/configure.ac index 07428e2d11b26b..82593f37f1bbcc 100644 --- a/configure.ac +++ b/configure.ac @@ -1826,7 +1826,7 @@ if test "$Py_OPT" = 'true' ; then # Check for conflicting CFLAGS=-O0 and --enable-optimizations case "$CFLAGS" in *-O0*) - AC_MSG_ERROR([CFLAGS contains -O0 which conflicts with --enable-optimizations. Please remove -O0 from CFLAGS or do not use --enable-optimizations.]) + AC_MSG_WARN([CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance.]) ;; esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not From 69d165975f591d5675a5645cd7a6b50b0c7fa241 Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Wed, 27 Aug 2025 03:17:03 +0900 Subject: [PATCH 3/6] Update configure.ac Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 82593f37f1bbcc..9f0556786be42d 100644 --- a/configure.ac +++ b/configure.ac @@ -1826,7 +1826,9 @@ if test "$Py_OPT" = 'true' ; then # Check for conflicting CFLAGS=-O0 and --enable-optimizations case "$CFLAGS" in *-O0*) - AC_MSG_WARN([CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance.]) + AC_MSG_WARN([CFLAGS contains -O0 which may conflict with \ + --enable-optimizations. Consider removing -O0 from CFLAGS \ + for optimal performance.]) ;; esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not From 75d8d677abdb987933c3617056c16d28e4b84aca Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Tue, 26 Aug 2025 15:28:36 -0400 Subject: [PATCH 4/6] update configure --- configure | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configure b/configure index bdeab8a6d126a3..b1bffa3d569adc 100755 --- a/configure +++ b/configure @@ -8410,8 +8410,12 @@ if test "$Py_OPT" = 'true' ; then # Check for conflicting CFLAGS=-O0 and --enable-optimizations case "$CFLAGS" in *-O0*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance." >&5 -printf "%s\n" "$as_me: WARNING: CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance." >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: CFLAGS contains -O0 which may conflict with \ + --enable-optimizations. Consider removing -O0 from CFLAGS \ + for optimal performance." >&5 +printf "%s\n" "$as_me: WARNING: CFLAGS contains -O0 which may conflict with \ + --enable-optimizations. Consider removing -O0 from CFLAGS \ + for optimal performance." >&2;} ;; esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not From 634a247a354b9f94f94e7b3fbab40c49f33780cb Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 26 Aug 2025 21:18:33 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2025-08-26-21-18-32.gh-issue-128042.5voC8H.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2025-08-26-21-18-32.gh-issue-128042.5voC8H.rst diff --git a/Misc/NEWS.d/next/Build/2025-08-26-21-18-32.gh-issue-128042.5voC8H.rst b/Misc/NEWS.d/next/Build/2025-08-26-21-18-32.gh-issue-128042.5voC8H.rst new file mode 100644 index 00000000000000..fd85e0fee2162b --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-08-26-21-18-32.gh-issue-128042.5voC8H.rst @@ -0,0 +1 @@ +``./configure`` now warns when ``--enable-optimizations`` and ``CFLAGS=-O0`` are both set, suggesting removing ``-O0`` from ``CFLAGS`` for optimal performance. Patch by Taegyun Kim. From d9d751407f699660ee95b3c5a89b4a306d7418c3 Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Tue, 26 Aug 2025 17:51:28 -0400 Subject: [PATCH 6/6] use m4_normalize for multiline message --- configure | 8 ++------ configure.ac | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/configure b/configure index b1bffa3d569adc..bdeab8a6d126a3 100755 --- a/configure +++ b/configure @@ -8410,12 +8410,8 @@ if test "$Py_OPT" = 'true' ; then # Check for conflicting CFLAGS=-O0 and --enable-optimizations case "$CFLAGS" in *-O0*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: CFLAGS contains -O0 which may conflict with \ - --enable-optimizations. Consider removing -O0 from CFLAGS \ - for optimal performance." >&5 -printf "%s\n" "$as_me: WARNING: CFLAGS contains -O0 which may conflict with \ - --enable-optimizations. Consider removing -O0 from CFLAGS \ - for optimal performance." >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance." >&5 +printf "%s\n" "$as_me: WARNING: CFLAGS contains -O0 which may conflict with --enable-optimizations. Consider removing -O0 from CFLAGS for optimal performance." >&2;} ;; esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not diff --git a/configure.ac b/configure.ac index 9f0556786be42d..991fa40746be78 100644 --- a/configure.ac +++ b/configure.ac @@ -1826,9 +1826,9 @@ if test "$Py_OPT" = 'true' ; then # Check for conflicting CFLAGS=-O0 and --enable-optimizations case "$CFLAGS" in *-O0*) - AC_MSG_WARN([CFLAGS contains -O0 which may conflict with \ - --enable-optimizations. Consider removing -O0 from CFLAGS \ - for optimal performance.]) + AC_MSG_WARN([m4_normalize([ + CFLAGS contains -O0 which may conflict with --enable-optimizations. + Consider removing -O0 from CFLAGS for optimal performance.])]) ;; esac # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not