diff --git a/.cirrus.yml b/.cirrus.yml index c5a0280a78..a1c6e2203f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,13 +10,13 @@ btest_jobs: &BTEST_JOBS 4 btest_retries: &BTEST_RETRIES 2 memory: &MEMORY 16GB -config: &CONFIG --build-type=release --disable-broker-tests --prefix=$CIRRUS_WORKING_DIR/install --ccache -no_spicy_config: &NO_SPICY_CONFIG --build-type=release --disable-broker-tests --disable-spicy --prefix=$CIRRUS_WORKING_DIR/install --ccache -static_config: &STATIC_CONFIG --build-type=release --disable-broker-tests --enable-static-broker --enable-static-binpac --prefix=$CIRRUS_WORKING_DIR/install --ccache -asan_sanitizer_config: &ASAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=address --enable-fuzzers --enable-coverage --disable-spicy --ccache -ubsan_sanitizer_config: &UBSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=undefined --enable-fuzzers --disable-spicy --ccache -tsan_sanitizer_config: &TSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=thread --enable-fuzzers --disable-spicy --ccache -openssl30_config: &OPENSSL30_CONFIG --build-type=release --disable-broker-tests --with-openssl=/opt/openssl --prefix=$CIRRUS_WORKING_DIR/install --ccache +config: &CONFIG --build-type=release --disable-broker-tests --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror +no_spicy_config: &NO_SPICY_CONFIG --build-type=release --disable-broker-tests --disable-spicy --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror +static_config: &STATIC_CONFIG --build-type=release --disable-broker-tests --enable-static-broker --enable-static-binpac --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror +asan_sanitizer_config: &ASAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=address --enable-fuzzers --enable-coverage --disable-spicy --ccache --enable-werror +ubsan_sanitizer_config: &UBSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=undefined --enable-fuzzers --disable-spicy --ccache --enable-werror +tsan_sanitizer_config: &TSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=thread --enable-fuzzers --disable-spicy --ccache --enable-werror +openssl30_config: &OPENSSL30_CONFIG --build-type=release --disable-broker-tests --with-openssl=/opt/openssl --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror resources_template: &RESOURCES_TEMPLATE cpu: *CPUS diff --git a/CMakeLists.txt b/CMakeLists.txt index 94119d4c96..eeffce462e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,8 +165,18 @@ if (MSVC) # Disable Spicy as it is not yet supported in Windows. set(DISABLE_SPICY true) + + if (BUILD_WITH_WERROR) + # TODO: This is disabled for now because there a bunch of known + # compiler warnings on Windows that we don't have good fixes for. + #set(WERROR_FLAG "/WX") + #set(WERROR_FLAG "/WX") + endif () else () include(GNUInstallDirs) + if (BUILD_WITH_WERROR) + set(WERROR_FLAG "-Werror") + endif () endif () include(cmake/CommonCMakeConfig.cmake) @@ -254,6 +264,7 @@ endif () foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) if (TARGET ${name}) target_compile_definitions(${name} PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) + target_compile_options(${name} PRIVATE ${WERROR_FLAG}) endif () endforeach () @@ -347,6 +358,7 @@ function (zeek_add_subdir_library name) add_dependencies(${target_name} zeek_autogen_files) target_link_libraries(${target_name} PRIVATE $) add_clang_tidy_files(${FN_ARGS_SOURCES}) + target_compile_options(${target_name} PRIVATE ${WERROR_FLAG}) # Take care of compiling BIFs. if (FN_ARGS_BIFS) diff --git a/cmake b/cmake index 507d120121..01fcb68300 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 507d1201213a7b308298e0c5d6ac0c9f870e2bb8 +Subproject commit 01fcb683005e3c3a71ae867aa983b772a77e32d1 diff --git a/configure b/configure index e74d38280e..18f019b29c 100755 --- a/configure +++ b/configure @@ -64,6 +64,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --enable-perftools-debug use Google's perftools for debugging --enable-static-binpac build binpac statically (ignored if --with-binpac is specified) --enable-static-broker build Broker statically (ignored if --with-broker is specified) + --enable-werror build with -Werror --disable-af-packet don't include native AF_PACKET support (Linux only) --disable-archiver don't build or install zeek-archiver tool --disable-auxtools don't build or install auxiliary tools @@ -275,6 +276,9 @@ while [ $# -ne 0 ]; do --enable-static-broker) append_cache_entry BUILD_STATIC_BROKER BOOL true ;; + --enable-werror) + append_cache_entry BUILD_WITH_WERROR BOOL true + ;; --disable-af-packet) append_cache_entry DISABLE_AF_PACKET BOOL true ;; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27f0834715..4101e97be1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,8 +41,16 @@ set(BISON_FLAGS "--debug") if (MSVC) set(SIGN_COMPARE_FLAG "/wd4018") + if (BUILD_WITH_WERROR) + # TODO: This is disabled for now because there a bunch of known + # compiler warnings on Windows that we don't have good fixes for. + #set(WERROR_FLAG "/WX") + endif () else () set(SIGN_COMPARE_FLAG "-Wno-sign-compare") + if (BUILD_WITH_WERROR) + set(WERROR_FLAG "-Werror") + endif () endif () # Rule parser/scanner @@ -517,6 +525,7 @@ collect_headers(zeek_HEADERS ${zeek_SRCS}) add_library(zeek_objs OBJECT ${zeek_SRCS}) target_compile_features(zeek_objs PRIVATE ${ZEEK_CXX_STD}) +target_compile_options(zeek_objs PRIVATE ${WERROR_FLAG}) set_target_properties(zeek_objs PROPERTIES CXX_EXTENSIONS OFF) target_link_libraries(zeek_objs PRIVATE $) target_compile_definitions(zeek_objs PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) @@ -530,6 +539,7 @@ endif () if (TARGET zeek_exe) target_sources(zeek_exe PRIVATE main.cc ${zeek_HEADERS}) + target_compile_options(zeek_exe PRIVATE ${WERROR_FLAG}) # npcap/winpcap need to be loaded in delayed mode so that we can set the load # path correctly at runtime. See @@ -553,6 +563,7 @@ endif () if (TARGET zeek_lib) target_sources(zeek_lib PRIVATE ${zeek_HEADERS}) + target_compile_options(zeek_lib PRIVATE ${WERROR_FLAG}) target_link_libraries(zeek_lib PUBLIC ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) endif ()