fix(build): probe positive form of -Wdeprecated-enum-enum-conversion - #11051
fix(build): probe positive form of -Wdeprecated-enum-enum-conversion#11051MarkAtwood wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Autoconf probe that conditionally adds -Wno-deprecated-enum-enum-conversion so the check no longer “succeeds” on compilers that don’t actually support the warning option (notably due to GCC’s behavior with unknown -Wno-* flags in trivial conftests).
Changes:
- Switch the probe from
-Wno-deprecated-enum-enum-conversionto the positive-Wdeprecated-enum-enum-conversionform. - Remove the previous
ac_c_werror_flagsave/restore logic around the probe. - Update the surrounding comments to explain why probing
-Wno-*is unreliable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| AX_CHECK_COMPILE_FLAG([-Wdeprecated-enum-enum-conversion], | ||
| [AX_APPEND_FLAG([-Wno-deprecated-enum-enum-conversion], [AM_CFLAGS])]) |
|
@douzzer — you added this probe in 627f516 ("add Which build path was meant to receive the flag?
Two readings, with different consequences: (a) It's for (b) It was meant for C++ compilation and landed in I deliberately didn't guess: moving it under (a) would silently drop C++20 suppression someone depends on, and leaving it under (b) enshrines config that does nothing. Worth noting this PR is safe under either reading — it never adds the flag to a compiler that rejects it, so the deferred-diagnostic failure can't recur regardless. It's just that (b) would want a follow-up. Context on why this surfaced: the flag has been silently riding in |
Fixes jenkins issue
#559— https://jenkins-supervisor.wolfssl.com/#/open-issues/559(root-cause task
#556: https://jenkins-supervisor.wolfssl.com/#/open-issues/556)Problem
The probe added in 627f516 intends to add
-Wno-deprecated-enum-enum-conversiononly "if applicable". It does not achieve that: the flag is accepted on compilers that have never heard of it.GCC reports an unrecognized
-Wno-fooonly if some other diagnostic is emitted in the same translation unit.AX_CHECK_COMPILE_FLAG's conftest is trivial and emits nothing, so there is no stderr forac_c_werror_flag=yesto catch, and the probe returns yes. The flag is then appended toAM_CFLAGS, reaching every C translation unit in the tree.It causes no trouble at all until an unrelated warning shows up. Then the deferred complaint fires and
-Werrorconverts a single warning into two hard errors:The second error is pure noise that sends you looking in the wrong place — it appears and disappears purely as a function of whether anything else in the file warned.
Fix
Probe the positive
-Wdeprecated-enum-enum-conversion, which GCC rejects immediately and unconditionally when unknown, then append the-Wno-form on success. Theac_c_werror_flagjuggling is no longer needed.Verification
Measured on gcc 9.4.0 (Ubuntu 20.04), the compiler where this actually bites:
-Werror -Wno-deprecated-enum-enum-conversion(current)-Wdeprecated-enum-enum-conversion(this PR)gcc: error: unrecognized command line option— correctly skippedBehaviour after this change:
-Wno-form added, original intent preservedAlso confirmed the flag really does land in C flags today:
AM_CFLAGSin a generatedMakefilecontains it, andconfig.logshows it baked in at configure time.Question for the original author
configure.achas noAC_PROG_CXX, noAM_CXXFLAGS, and compiles no C++, so it isn't obvious which build path was meant to receive this..github/workflows/multi-compiler.ymlpassesCXX=g++-9..12/clang++-14,19to configure. If the intended target is genuinely C++ compilation,AM_CXXFLAGSunderAC_LANG_PUSH([C++])would be the more precise home and I'm glad to redo it that way.Independent of #11050, which fixes the
-Wtype-limitswarning that exposed this. Either PR alone makes the observed failure go away; only this one disarms it for the next warning.