commit 97c9ced70ac364f7067fc088b90184ab77c9ecd9 Author: Nick Mathewson nickm@torproject.org Date: Fri Dec 21 09:49:33 2018 -0500
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. --- .gitignore | 3 +++ configure.ac | 38 +++++++++++++++++++++++++++++--------- warning_flags.in | 1 + 3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore index cedff8fb3..f1ce903a1 100644 --- a/.gitignore +++ b/.gitignore @@ -72,9 +72,12 @@ uptime-*.json /mkinstalldirs /Tor*Bundle.dmg /tor-*-win32.exe +/warning_flags + /coverage_html/ /callgraph/
+ # /contrib/ /contrib/dist/tor.sh /contrib/dist/torctl diff --git a/configure.ac b/configure.ac index 1d4c31f86..d992b8d01 100644 --- a/configure.ac +++ b/configure.ac @@ -2129,6 +2129,8 @@ case "$host_os" in LDFLAGS="$LDFLAGS -dead_strip" ;; esac
+TOR_WARNING_FLAGS="" + # Add some more warnings which we use in development but not in the # 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" ;; esac
+ CFLAGS_NOWARNINGS="$CFLAGS" + # GCC4.3 users once report trouble with -Wstrict-overflow=5. GCC5 users # have it work better. # CFLAGS="$CFLAGS -Wstrict-overflow=1" @@ -2361,7 +2365,9 @@ if test "x$enable_gcc_warnings_advisory" != "xno"; then -Wvisibility -Wvla-extension -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 mind, but it causes trouble with GCC. @@ -2375,16 +2381,19 @@ dnl -Wthread-safety-attributes dnl -Wthread-safety-beta dnl -Wthread-safety-precise
- CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith" - CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings" - CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2" - CFLAGS="$CFLAGS -Wwrite-strings" - CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum" - CFLAGS="$CFLAGS -Waggregate-return -Wpacked -Wunused" - CFLAGS="$CFLAGS -Wunused-parameter " + W_FLAGS="$W_FLAGS -W -Wfloat-equal -Wundef -Wpointer-arith" + W_FLAGS="$W_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings" + W_FLAGS="$W_FLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2" + W_FLAGS="$W_FLAGS -Wwrite-strings" + W_FLAGS="$W_FLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum" + W_FLAGS="$W_FLAGS -Waggregate-return -Wpacked -Wunused" + W_FLAGS="$W_FLAGS -Wunused-parameter " # These interfere with building main() { return 0; }, which autoconf # 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 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]) fi
+ CFLAGS="$CFLAGS_NOWARNINGS" + if test "x$enable_fatal_warnings" = "xyes"; then # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the # default autoconf programs are full of errors. @@ -2404,6 +2415,14 @@ dnl -Wthread-safety-precise
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 case "$host_os" in darwin*) @@ -2427,6 +2446,7 @@ AC_CONFIG_FILES([ src/rust/.cargo/config scripts/maint/checkOptionDocs.pl scripts/maint/updateVersions.pl + warning_flags ])
if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then diff --git a/warning_flags.in b/warning_flags.in new file mode 100644 index 000000000..e8ebe6e9a --- /dev/null +++ b/warning_flags.in @@ -0,0 +1 @@ +@TOR_WARNING_FLAGS@ \ No newline at end of file
tor-commits@lists.torproject.org