From: Ken Raeburn Date: Sat, 7 Jan 2017 03:39:39 +0000 (-0500) Subject: Fix detection of supported warnings in clang X-Git-Tag: krb5-1.16-beta1~167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9f915d4079a8d6b4d6bc6381b8c05167c64e042;p=thirdparty%2Fkrb5.git Fix detection of supported warnings in clang Without -Werror=unknown-warning-option, clang will warn for unrecognized -W options like "-Werror=discarded-qualifiers" but won't return a nonzero exit status, leading configure to think the options are supported and thus include them during the build, leading to a rather noisy log. This option isn't needed during the build, though it won't hurt anything either. It is desirable during the testing of other -W options for cleaner results, but the existing code tests each option independently, requiring different handling for this option than for other -W options. --- diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 510d9ba519..0a2df0e016 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -450,13 +450,13 @@ krb5_ac_warn_cflags_set=${WARN_CFLAGS+set} krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set} ]) dnl -AC_DEFUN(TRY_WARN_CC_FLAG,[dnl +AC_DEFUN(TRY_WARN_CC_FLAG_1,[dnl cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g` AC_CACHE_CHECK([if C compiler supports $1], [$cachevar], [# first try without, then with AC_TRY_COMPILE([], 1;, [old_cflags="$CFLAGS" - CFLAGS="$CFLAGS $1" + CFLAGS="$CFLAGS $cflags_warning_test_flags $1" AC_TRY_COMPILE([], 1;, eval $cachevar=yes, eval $cachevar=no) CFLAGS="$old_cflags"], [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])]) @@ -466,6 +466,21 @@ AC_DEFUN(TRY_WARN_CC_FLAG,[dnl eval flag_supported='${'$cachevar'}' ])dnl dnl +dnl Are additional flags needed to make unsupported warning options +dnl get reported as errors? +AC_DEFUN(CHECK_CC_WARNING_TEST_FLAGS,[dnl + cflags_warning_test_flags= + TRY_WARN_CC_FLAG_1(-Werror=unknown-warning-option) + if test $flag_supported = yes; then + cflags_warning_test_flags=-Werror=unknown-warning-option + fi +])dnl +dnl +AC_DEFUN(TRY_WARN_CC_FLAG,[dnl +AC_REQUIRE([CHECK_CC_WARNING_TEST_FLAGS])dnl +TRY_WARN_CC_FLAG_1($1)dnl +])dnl +dnl AC_DEFUN(WITH_CC,[dnl AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl AC_REQUIRE([AC_PROG_CC])dnl