aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-02-23 10:48:11 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-02-23 10:48:46 +0100
commite68c266f3d56d1a78bb79bea48bce3dc8ef29e6e (patch)
tree62885b4a3cb6ead618d8c20a2ad7fe3efa7e839f
parent1d2a57e9fd2cfc0d82d9770d7bcdcc61463bbc74 (diff)
parent205830a37b7ffa4f8fa306e5c9eafcee3777fa68 (diff)
Merge #9789: build: add --enable-werror and warn on vla's
205830a build: add --enable-werror option (Cory Fields) b602fe0 build: warn about variable length arrays (Cory Fields)
-rw-r--r--configure.ac18
-rw-r--r--src/Makefile.am2
2 files changed, 19 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 78129fb202..7a02237df7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -192,6 +192,13 @@ AC_ARG_ENABLE([debug],
[enable_debug=$enableval],
[enable_debug=no])
+# Turn warnings into errors
+AC_ARG_ENABLE([werror],
+ [AS_HELP_STRING([--enable-werror],
+ [Treat certain compiler warnings as errors (default is no)])],
+ [enable_werror=$enableval],
+ [enable_werror=no])
+
AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""])
@@ -206,10 +213,19 @@ if test "x$enable_debug" = xyes; then
fi
fi
+ERROR_CXXFLAGS=
+if test "x$enable_werror" = "xyes"; then
+ if test "x$CXXFLAG_WERROR" = "x"; then
+ AC_MSG_ERROR("enable-werror set but -Werror is not usable")
+ fi
+ AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]])
+fi
+
if test "x$CXXFLAGS_overridden" = "xno"; then
AX_CHECK_COMPILE_FLAG([-Wall],[CXXFLAGS="$CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
+ AX_CHECK_COMPILE_FLAG([-Wvla],[CXXFLAGS="$CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
@@ -1066,6 +1082,7 @@ AC_SUBST(BITCOIN_CLI_NAME)
AC_SUBST(BITCOIN_TX_NAME)
AC_SUBST(RELDFLAGS)
+AC_SUBST(ERROR_CXXFLAGS)
AC_SUBST(HARDENED_CXXFLAGS)
AC_SUBST(HARDENED_CPPFLAGS)
AC_SUBST(HARDENED_LDFLAGS)
@@ -1155,6 +1172,7 @@ echo " with test = $use_tests"
echo " with bench = $use_bench"
echo " with upnp = $use_upnp"
echo " debug enabled = $enable_debug"
+echo " werror = $enable_werror"
echo
echo " target os = $TARGET_OS"
echo " build os = $BUILD_OS"
diff --git a/src/Makefile.am b/src/Makefile.am
index a2072865a3..e8d22313dc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@
DIST_SUBDIRS = secp256k1 univalue
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS)
-AM_CXXFLAGS = $(HARDENED_CXXFLAGS)
+AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
EXTRA_LIBRARIES =