From 2af1c34b778bbd94aa553c44ffbc4dba3ba34739 Mon Sep 17 00:00:00 2001 From: Mark Atwood Date: Tue, 4 Aug 2026 09:50:22 -0700 Subject: [PATCH] fix(build): probe positive enum-enum warning flag AX_CHECK_COMPILE_FLAG([-Wno-deprecated-enum-enum-conversion]) succeeds on compilers that do not support the option. gcc only reports an unrecognized -Wno-foo when some other diagnostic is emitted in the same translation unit, and the trivial conftest emits nothing, so neither -Werror nor ac_c_werror_flag has anything to trip on. The flag is then appended to AM_CFLAGS and reaches every C translation unit. It stays silent until an unrelated warning appears, at which point gcc reports the deferred complaint and -Werror turns one warning into two hard errors: error: comparison of unsigned expression < 0 is always false cc1: error: unrecognized command line option '-Wno-deprecated-enum-enum-conversion' [-Werror] Probe the positive -Wdeprecated-enum-enum-conversion instead, which gcc rejects immediately when unknown, and keep appending the -Wno- form on success. Measured on gcc 9.4.0: the positive probe exits 1 with "unrecognized command line option", so the flag is correctly skipped. --- configure.ac | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index a73a51f4f60..d27cfc961df 100644 --- a/configure.ac +++ b/configure.ac @@ -12822,14 +12822,12 @@ fi # our use of enum constructs to define fungible constants. if test "$KERNEL_MODE_DEFAULTS" != "yes" then - # Probe with ac_c_werror_flag (fail on any stderr output), not -Werror: - # ccache reorders -Werror after the -Wno- option, so gcc accepts it with - # only a warning. - ax_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - AX_CHECK_COMPILE_FLAG([-Wno-deprecated-enum-enum-conversion], + # Probe the positive form: gcc rejects an unknown -Wfoo outright, but + # only reports an unknown -Wno-foo if some other diagnostic is emitted, + # which a trivial conftest never produces. Probing -Wno- therefore + # succeeds on compilers that do not support the option at all. + AX_CHECK_COMPILE_FLAG([-Wdeprecated-enum-enum-conversion], [AX_APPEND_FLAG([-Wno-deprecated-enum-enum-conversion], [AM_CFLAGS])]) - ac_c_werror_flag=$ax_save_c_werror_flag fi case $host_os in