diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-01-08 14:40:23 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-01-08 14:40:38 +0100 |
commit | b065df803ce2969193ff273457cceb781b433177 (patch) | |
tree | 45167243b5068a235e88a47c407e3d6cdc2cdb8b | |
parent | 07efb3fe2ba4c54ba49840af3a7510d5d3baae79 (diff) | |
parent | b0a254019c3bc8a353c1304ee65a55cfb3d4ecac (diff) |
Merge #17880: build: add -Wdate-time to Werror flags
b0a254019c3bc8a353c1304ee65a55cfb3d4ecac build: add Wdate-time to Werror flags (fanquake)
Pull request description:
`-Wdate-time`
Warn when macros __TIME__, __DATE__ or __TIMESTAMP__ are encountered as
they might prevent bit-wise-identical reproducible compilations.
This is supported by [GCC](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html) and [Clang](https://clang.llvm.org/docs/DiagnosticsReference.html#wdate-time).
Example output:
```bash
CXX bitcoind-bitcoind.o
bitcoind.cpp:48:20: warning: expansion of date or time macro is not reproducible [-Wdate-time]
printf("%s\n", __TIMESTAMP__);
^
bitcoind.cpp:49:20: warning: expansion of date or time macro is not reproducible [-Wdate-time]
printf("%s\n", __TIME__);
^
bitcoind.cpp:50:20: warning: expansion of date or time macro is not reproducible [-Wdate-time]
printf("%s\n", __DATE__);
^
3 warnings generated.
```
ACKs for top commit:
practicalswift:
ACK b0a254019c3bc8a353c1304ee65a55cfb3d4ecac -- diff looks correct and guarding against potential non-reproducibility is good :)
promag:
Tested ACK b0a254019c3bc8a353c1304ee65a55cfb3d4ecac on macos with clang. Already had `--enable-werror`, added a wild `printf("%s\n", __TIMESTAMP__)` and got the following error:
laanwj:
ACK b0a254019c3bc8a353c1304ee65a55cfb3d4ecac
hebasto:
ACK b0a254019c3bc8a353c1304ee65a55cfb3d4ecac
Tree-SHA512: b3a0b426e06dcd0c0baa94118c31158760b9690a8d0a15b5a2d544cb0879522e02817e134ef7346c707de09719818fc7e4bad1b3ad6b2dfe5e3c4169cdf5cb0d
-rw-r--r-- | configure.ac | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 875491fb99..888f67cc87 100644 --- a/configure.ac +++ b/configure.ac @@ -329,6 +329,7 @@ if test "x$enable_werror" = "xyes"; then AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=thread-safety-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety-analysis"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]]) fi if test "x$CXXFLAGS_overridden" = "xno"; then @@ -342,6 +343,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wrange-loop-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wrange-loop-analysis"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]]) dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all dnl unknown options if any other warning is produced. Test the -Wfoo case, and |