]> The Tcpdump Group git mirrors - tcpdump/commit
configure: use ac_c_werror_flag to force unknown compiler flags to fail.
authorGuy Harris <[email protected]>
Sun, 25 Jul 2021 09:22:42 +0000 (02:22 -0700)
committerGuy Harris <[email protected]>
Sun, 25 Jul 2021 09:22:42 +0000 (02:22 -0700)
commit95ae3ed835f5b3f285bef75fe7913a58df9461aa
treee7903028f5ed54de7fe18a190f6cf8305ba43b33
parent34fd411f222dd93868ae677dbe8ae82d09f9f199
configure: use ac_c_werror_flag to force unknown compiler flags to fail.

It's not a documented feature, but it's what the documented
AC_LANG_WERROR has used for 13 years, and there's no push/pop mechanism
for AC_LANG_WERROR, so you can't ensure that "fail even on warnings"
will be applied *only* in AC_LBL_CHECK_COMPILER_OPT(), as that's what we
want.  (If we can make sure that *no* compiler tests will produce
warnings, except for the ones we *want* to fail if they produce
warnings, we could just do AC_LANG_WERROR, but that might be tricky to
ensure in the general case.)

We do this because not all compilers have a command-line flag to force
all warnings, *including* warnings from unknown commad-line flags (I'm
looking at *you* IBM XL C!), so we have to have the test check to make
sure no warnings are produced (which, for AC_TRY_COMPILE(), means
"nothing is written to the standard output").

In addition, AC_TRY_COMPILE() generates a return; don't add one:

If we pass [return 0] to AC_TRY_COMPILE(), the test program it compiles
has two "return 0;" statements in a row, and one of the -W flags we
tests reports a warning for that.

We were testing whether a -W flag is supported by checking the standard
error of the compiler to see if *any* error/warning messages are
generated, and treating the flag as unsupported if any are, that meant
that -Wunreachable-code-return was be treated as unsupported even though
it *is* supported.

This should fix that.  (I'm so glad autoconf makes this all so difficult
to do correctly....)
aclocal.m4
configure