Grep for clang warnings when testing compiler flag support
There is no way to make clang's "argument unused" warning fatal. Ideally the search string would also include 'clang: ' but this output might depend on clang's argv[0].
This commit is contained in:
committed by
Keith Winstein
parent
b5ab0d0736
commit
62b6137ff5
@@ -44,6 +44,18 @@ AC_ARG_ENABLE([compile-warnings],
|
|||||||
AC_SUBST([WARNING_CXXFLAGS])
|
AC_SUBST([WARNING_CXXFLAGS])
|
||||||
AC_SUBST([PICKY_CXXFLAGS])
|
AC_SUBST([PICKY_CXXFLAGS])
|
||||||
|
|
||||||
|
# We want to check for compiler flag support, but there is no way to make
|
||||||
|
# clang's "argument unused" warning fatal. So we invoke the compiler through a
|
||||||
|
# wrapper script that greps for this message.
|
||||||
|
|
||||||
|
saved_CC="$CC"
|
||||||
|
saved_CXX="$CXX"
|
||||||
|
saved_LD="$LD"
|
||||||
|
flag_wrap="$srcdir/scripts/wrap-compiler-for-flag-check"
|
||||||
|
CC="$flag_wrap $CC"
|
||||||
|
CXX="$flag_wrap $CXX"
|
||||||
|
LD="$flag_wrap $LD"
|
||||||
|
|
||||||
# We use the same hardening flags for C and C++. We must check that each flag
|
# We use the same hardening flags for C and C++. We must check that each flag
|
||||||
# is supported by both compilers.
|
# is supported by both compilers.
|
||||||
AC_DEFUN([check_cc_cxx_flag],
|
AC_DEFUN([check_cc_cxx_flag],
|
||||||
@@ -89,6 +101,10 @@ AS_IF([test x"$hardening" != x"no"], [
|
|||||||
AC_SUBST([HARDEN_CFLAGS])
|
AC_SUBST([HARDEN_CFLAGS])
|
||||||
AC_SUBST([HARDEN_LDFLAGS])
|
AC_SUBST([HARDEN_LDFLAGS])
|
||||||
|
|
||||||
|
CC="$saved_CC"
|
||||||
|
CXX="$saved_CXX"
|
||||||
|
LD="$saved_LD"
|
||||||
|
|
||||||
AC_ARG_ENABLE([client],
|
AC_ARG_ENABLE([client],
|
||||||
[AS_HELP_STRING([--enable-client], [Build the mosh-client program @<:@yes@:>@])],
|
[AS_HELP_STRING([--enable-client], [Build the mosh-client program @<:@yes@:>@])],
|
||||||
[build_client="$enableval"],
|
[build_client="$enableval"],
|
||||||
|
|||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# There is no way to make clang's "argument unused" warning fatal. So when
|
||||||
|
# configure checks for supported flags, it runs $CC, $CXX, $LD via this
|
||||||
|
# wrapper.
|
||||||
|
#
|
||||||
|
# Ideally the search string would also include 'clang: ' but this output might
|
||||||
|
# depend on clang's argv[0].
|
||||||
|
|
||||||
|
if out=`"$@" 2>&1`; then
|
||||||
|
echo "$out"
|
||||||
|
if echo "$out" | grep 'warning: argument unused' >/dev/null; then
|
||||||
|
echo "$0: found clang warning"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
code=$?
|
||||||
|
echo "$out"
|
||||||
|
exit $code
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user