Try @warning_flags to avoid bloating verbose make logs

We now accumulate warning flags in a separate variable,
"TOR_WARNING_FLAGS", and write it to a "warning_flags" file.  Then
we test whether the compiler will accept "@warning_flags": if so, we
put "@warning_flags" in the CFLAGS; if not, we copy the contents of
"$TOR_WARNING_FLAGS" into the CFLAGS.

Closes ticket 28924.
This commit is contained in:
Nick Mathewson 2018-12-21 09:49:33 -05:00
parent ef97543270
commit 97c9ced70a
3 changed files with 33 additions and 9 deletions

3
.gitignore vendored
View File

@ -72,9 +72,12 @@ uptime-*.json
/mkinstalldirs /mkinstalldirs
/Tor*Bundle.dmg /Tor*Bundle.dmg
/tor-*-win32.exe /tor-*-win32.exe
/warning_flags
/coverage_html/ /coverage_html/
/callgraph/ /callgraph/
# /contrib/ # /contrib/
/contrib/dist/tor.sh /contrib/dist/tor.sh
/contrib/dist/torctl /contrib/dist/torctl

View File

@ -2129,6 +2129,8 @@ case "$host_os" in
LDFLAGS="$LDFLAGS -dead_strip" ;; LDFLAGS="$LDFLAGS -dead_strip" ;;
esac esac
TOR_WARNING_FLAGS=""
# Add some more warnings which we use in development but not in the # Add some more warnings which we use in development but not in the
# released versions. (Some relevant gcc versions can't handle these.) # released versions. (Some relevant gcc versions can't handle these.)
# #
@ -2146,6 +2148,8 @@ if test "x$enable_gcc_warnings_advisory" != "xno"; then
CFLAGS="$CFLAGS -Wno-system-headers" ;; CFLAGS="$CFLAGS -Wno-system-headers" ;;
esac esac
CFLAGS_NOWARNINGS="$CFLAGS"
# GCC4.3 users once report trouble with -Wstrict-overflow=5. GCC5 users # GCC4.3 users once report trouble with -Wstrict-overflow=5. GCC5 users
# have it work better. # have it work better.
# CFLAGS="$CFLAGS -Wstrict-overflow=1" # CFLAGS="$CFLAGS -Wstrict-overflow=1"
@ -2361,7 +2365,9 @@ if test "x$enable_gcc_warnings_advisory" != "xno"; then
-Wvisibility -Wvisibility
-Wvla-extension -Wvla-extension
-Wzero-length-array -Wzero-length-array
], [ TOR_CHECK_CFLAGS([warning_flag]) ]) ], [ TOR_TRY_COMPILE_WITH_CFLAGS(warning_flag, [],
[TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS warning_flag" CFLAGS="$CFLAGS warning_flag"], true)
])
dnl We should re-enable this in some later version. Clang doesn't dnl We should re-enable this in some later version. Clang doesn't
dnl mind, but it causes trouble with GCC. dnl mind, but it causes trouble with GCC.
@ -2375,16 +2381,19 @@ dnl -Wthread-safety-attributes
dnl -Wthread-safety-beta dnl -Wthread-safety-beta
dnl -Wthread-safety-precise dnl -Wthread-safety-precise
CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith" W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings" W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2" W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
CFLAGS="$CFLAGS -Wwrite-strings" W_FLAGS="$W_FLAGS -Wwrite-strings"
CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum" W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
CFLAGS="$CFLAGS -Waggregate-return -Wpacked -Wunused" W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused"
CFLAGS="$CFLAGS -Wunused-parameter " W_FLAGS="$W_FLAGS -Wunused-parameter "
# These interfere with building main() { return 0; }, which autoconf # These interfere with building main() { return 0; }, which autoconf
# likes to use as its default program. # likes to use as its default program.
CFLAGS="$CFLAGS -Wold-style-definition -Wmissing-declarations" W_FLAGS="$W_FLAGS -Wold-style-definition -Wmissing-declarations"
TOR_WARNING_FLAGS="$TOR_WARNING_FLAGS $W_FLAGS"
CFLAGS="$CFLAGS $W_FLAGS"
if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then if test "$tor_cv_cflags__Wnull_dereference" = "yes"; then
AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference]) AC_DEFINE([HAVE_CFLAG_WNULL_DEREFERENCE], 1, [True if we have -Wnull-dereference])
@ -2396,6 +2405,8 @@ dnl -Wthread-safety-precise
AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable]) AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable])
fi fi
CFLAGS="$CFLAGS_NOWARNINGS"
if test "x$enable_fatal_warnings" = "xyes"; then if test "x$enable_fatal_warnings" = "xyes"; then
# I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
# default autoconf programs are full of errors. # default autoconf programs are full of errors.
@ -2404,6 +2415,14 @@ dnl -Wthread-safety-precise
fi fi
AC_SUBST(TOR_WARNING_FLAGS)
echo "$TOR_WARNING_FLAGS">warning_flags
TOR_TRY_COMPILE_WITH_CFLAGS([@warning_flags], [],
CFLAGS="$CFLAGS @warning_flags",
CFLAGS="$CFLAGS $TOR_WARNING_FLAGS")
if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
case "$host_os" in case "$host_os" in
darwin*) darwin*)
@ -2427,6 +2446,7 @@ AC_CONFIG_FILES([
src/rust/.cargo/config src/rust/.cargo/config
scripts/maint/checkOptionDocs.pl scripts/maint/checkOptionDocs.pl
scripts/maint/updateVersions.pl scripts/maint/updateVersions.pl
warning_flags
]) ])
if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then

1
warning_flags.in Normal file
View File

@ -0,0 +1 @@
@TOR_WARNING_FLAGS@