Skip to content

Commit

Permalink
Fix detection of supported warnings in clang
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ken Raeburn authored and greghudson committed Jan 9, 2017
1 parent 87bcdce commit b9f915d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)])])
Expand All @@ -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
Expand Down

0 comments on commit b9f915d

Please sign in to comment.