mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-19 09:50:29 +01:00
Merge remote-tracking branch 'public/ticket19044'
This commit is contained in:
commit
a0dd836098
5
changes/19044
Normal file
5
changes/19044
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
o Minor features (compilation):
|
||||||
|
- Our big list of extra GCC warnings is now enabled by default when
|
||||||
|
building with GCC (or with anything like Clang that claims to be
|
||||||
|
GCC-compatible). To make all warnings into fatal compilation errors,
|
||||||
|
pass --enable-fatal-warnings to configure. Closes ticket 19044.
|
26
configure.ac
26
configure.ac
@ -143,9 +143,11 @@ case "$host" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
AC_ARG_ENABLE(gcc-warnings,
|
AC_ARG_ENABLE(gcc-warnings,
|
||||||
AS_HELP_STRING(--enable-gcc-warnings, [enable verbose warnings]))
|
AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
|
||||||
|
AC_ARG_ENABLE(fatal-warnings,
|
||||||
|
AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
|
||||||
AC_ARG_ENABLE(gcc-warnings-advisory,
|
AC_ARG_ENABLE(gcc-warnings-advisory,
|
||||||
AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
|
AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
|
||||||
|
|
||||||
dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
|
dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
|
||||||
AC_ARG_ENABLE(gcc-hardening,
|
AC_ARG_ENABLE(gcc-hardening,
|
||||||
@ -1636,6 +1638,12 @@ else
|
|||||||
enable_gcc_warnings_advisory=no
|
enable_gcc_warnings_advisory=no
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Warnings implies advisory-warnings and -Werror.
|
||||||
|
if test "$enable_gcc_warnings" = "yes"; then
|
||||||
|
enable_gcc_warnings_advisory=yes
|
||||||
|
enable_fatal_warnings=yes
|
||||||
|
fi
|
||||||
|
|
||||||
# OS X Lion started deprecating the system openssl. Let's just disable
|
# OS X Lion started deprecating the system openssl. Let's just disable
|
||||||
# all deprecation warnings on OS X. Also, to potentially make the binary
|
# all deprecation warnings on OS X. Also, to potentially make the binary
|
||||||
# a little smaller, let's enable dead_strip.
|
# a little smaller, let's enable dead_strip.
|
||||||
@ -1648,8 +1656,7 @@ esac
|
|||||||
|
|
||||||
# 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.)
|
||||||
if test "x$enable_gcc_warnings" = "xyes" ||
|
if test "x$enable_gcc_warnings_advisory" != "xno"; then
|
||||||
test "x$enable_gcc_warnings_advisory" = "xyes"; then
|
|
||||||
|
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
|
||||||
#if !defined(__GNUC__) || (__GNUC__ < 4)
|
#if !defined(__GNUC__) || (__GNUC__ < 4)
|
||||||
@ -1671,7 +1678,6 @@ if test "x$enable_gcc_warnings" = "xyes" ||
|
|||||||
#error
|
#error
|
||||||
#endif])], have_gcc46=yes, have_gcc46=no)
|
#endif])], have_gcc46=yes, have_gcc46=no)
|
||||||
|
|
||||||
|
|
||||||
save_CFLAGS="$CFLAGS"
|
save_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="$CFLAGS -Wshorten-64-to-32"
|
CFLAGS="$CFLAGS -Wshorten-64-to-32"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
|
||||||
@ -1693,10 +1699,6 @@ if test "x$enable_gcc_warnings" = "xyes" ||
|
|||||||
CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
|
CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
|
||||||
CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
|
CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
|
||||||
|
|
||||||
if test "x$enable_gcc_warnings" = "xyes"; then
|
|
||||||
CFLAGS="$CFLAGS -Werror"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Disabled, so we can use mallinfo(): -Waggregate-return
|
# Disabled, so we can use mallinfo(): -Waggregate-return
|
||||||
|
|
||||||
if test "x$have_gcc4" = "xyes"; then
|
if test "x$have_gcc4" = "xyes"; then
|
||||||
@ -1733,7 +1735,11 @@ if test "x$enable_gcc_warnings" = "xyes" ||
|
|||||||
CFLAGS="$CFLAGS -Wshorten-64-to-32"
|
CFLAGS="$CFLAGS -Wshorten-64-to-32"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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.
|
||||||
|
CFLAGS="$CFLAGS -Werror"
|
||||||
|
fi
|
||||||
|
|
||||||
##This will break the world on some 64-bit architectures
|
##This will break the world on some 64-bit architectures
|
||||||
# CFLAGS="$CFLAGS -Winline"
|
# CFLAGS="$CFLAGS -Winline"
|
||||||
|
@ -3,7 +3,7 @@ Coding conventions for Tor
|
|||||||
|
|
||||||
tl;dr:
|
tl;dr:
|
||||||
|
|
||||||
- Run configure with `--enable-gcc-warnings`
|
- Run configure with `--enable-fatal-warnings`
|
||||||
- Run `make check-spaces` to catch whitespace errors
|
- Run `make check-spaces` to catch whitespace errors
|
||||||
- Document your functions
|
- Document your functions
|
||||||
- Write unit tests
|
- Write unit tests
|
||||||
@ -21,7 +21,7 @@ preference)
|
|||||||
|
|
||||||
Did you remember...
|
Did you remember...
|
||||||
|
|
||||||
- To build your code while configured with `--enable-gcc-warnings`?
|
- To build your code while configured with `--enable-fatal-warnings`?
|
||||||
- To run `make check-spaces` on your code?
|
- To run `make check-spaces` on your code?
|
||||||
- To run `make check-docs` to see whether all new options are on
|
- To run `make check-docs` to see whether all new options are on
|
||||||
the manpage?
|
the manpage?
|
||||||
@ -125,10 +125,10 @@ deviations from our C whitespace style. Generally, we use:
|
|||||||
`puts (x)`.
|
`puts (x)`.
|
||||||
- Function declarations at the start of the line.
|
- Function declarations at the start of the line.
|
||||||
|
|
||||||
We try hard to build without warnings everywhere. In particular, if you're
|
We try hard to build without warnings everywhere. In particular, if
|
||||||
using gcc, you should invoke the configure script with the option
|
you're using gcc, you should invoke the configure script with the
|
||||||
`--enable-gcc-warnings`. This will give a bunch of extra warning flags to
|
option `--enable-fatal-warnings`. This will tell the compiler
|
||||||
the compiler, and help us find divergences from our preferred C style.
|
to make all warnings into errors.
|
||||||
|
|
||||||
Functions to use; functions not to use
|
Functions to use; functions not to use
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
@ -15,7 +15,7 @@ Top-level smell-checks
|
|||||||
|
|
||||||
(Difficulty: easy)
|
(Difficulty: easy)
|
||||||
|
|
||||||
- Does it compile with `--enable-gcc-warnings`?
|
- Does it compile with `--enable-fatal-warnings`?
|
||||||
|
|
||||||
- Does `make check-spaces` pass?
|
- Does `make check-spaces` pass?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user