krb5 commit: Fix detection of supported warnings in clang

Greg Hudson ghudson at mit.edu
Mon Jan 9 15:16:57 EST 2017


https://github.com/krb5/krb5/commit/b9f915d4079a8d6b4d6bc6381b8c05167c64e042
commit b9f915d4079a8d6b4d6bc6381b8c05167c64e042
Author: Ken Raeburn <raeburn at mit.edu>
Date:   Fri Jan 6 22:39:39 2017 -0500

    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.

 src/aclocal.m4 |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/aclocal.m4 b/src/aclocal.m4
index 510d9ba..0a2df0e 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


More information about the cvs-krb5 mailing list