@@ -192,6 +192,13 @@ AC_ARG_ENABLE([debug],
192
192
[ enable_debug=$enableval] ,
193
193
[ enable_debug=no] )
194
194
195
+ # Turn warnings into errors
196
+ AC_ARG_ENABLE ( [ werror] ,
197
+ [ AS_HELP_STRING ( [ --enable-werror] ,
198
+ [ Treat certain compiler warnings as errors (default is no)] ) ] ,
199
+ [ enable_werror=$enableval] ,
200
+ [ enable_werror=no] )
201
+
195
202
AC_LANG_PUSH ( [ C++] )
196
203
AX_CHECK_COMPILE_FLAG ( [ -Werror] ,[ CXXFLAG_WERROR="-Werror"] ,[ CXXFLAG_WERROR=""] )
197
204
@@ -206,10 +213,19 @@ if test "x$enable_debug" = xyes; then
206
213
fi
207
214
fi
208
215
216
+ ERROR_CXXFLAGS=
217
+ if test "x$enable_werror" = "xyes"; then
218
+ if test "x$CXXFLAG_WERROR" = "x"; then
219
+ AC_MSG_ERROR ( "enable-werror set but - Werror is not usable" )
220
+ fi
221
+ AX_CHECK_COMPILE_FLAG ( [ -Werror=vla] ,[ ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"] ,,[ [ $CXXFLAG_WERROR] ] )
222
+ fi
223
+
209
224
if test "x$CXXFLAGS_overridden" = "xno"; then
210
225
AX_CHECK_COMPILE_FLAG ( [ -Wall] ,[ CXXFLAGS="$CXXFLAGS -Wall"] ,,[ [ $CXXFLAG_WERROR] ] )
211
226
AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,[ CXXFLAGS="$CXXFLAGS -Wextra"] ,,[ [ $CXXFLAG_WERROR] ] )
212
227
AX_CHECK_COMPILE_FLAG ( [ -Wformat] ,[ CXXFLAGS="$CXXFLAGS -Wformat"] ,,[ [ $CXXFLAG_WERROR] ] )
228
+ AX_CHECK_COMPILE_FLAG ( [ -Wvla] ,[ CXXFLAGS="$CXXFLAGS -Wvla"] ,,[ [ $CXXFLAG_WERROR] ] )
213
229
AX_CHECK_COMPILE_FLAG ( [ -Wformat-security] ,[ CXXFLAGS="$CXXFLAGS -Wformat-security"] ,,[ [ $CXXFLAG_WERROR] ] )
214
230
215
231
# # Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
@@ -1066,6 +1082,7 @@ AC_SUBST(BITCOIN_CLI_NAME)
1066
1082
AC_SUBST ( BITCOIN_TX_NAME )
1067
1083
1068
1084
AC_SUBST ( RELDFLAGS )
1085
+ AC_SUBST ( ERROR_CXXFLAGS )
1069
1086
AC_SUBST ( HARDENED_CXXFLAGS )
1070
1087
AC_SUBST ( HARDENED_CPPFLAGS )
1071
1088
AC_SUBST ( HARDENED_LDFLAGS )
@@ -1155,6 +1172,7 @@ echo " with test = $use_tests"
1155
1172
echo " with bench = $use_bench"
1156
1173
echo " with upnp = $use_upnp"
1157
1174
echo " debug enabled = $enable_debug"
1175
+ echo " werror = $enable_werror"
1158
1176
echo
1159
1177
echo " target os = $TARGET_OS"
1160
1178
echo " build os = $BUILD_OS"
0 commit comments