diff --git a/CHANGES b/CHANGES index ae621860a8..af5be24f99 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,24 @@ +8.0.0-dev.636 | 2025-07-10 15:42:52 -0700 + + * Reduce some false-positive warnings from GCC to warnings with -Werror (Tim Wojtulewicz, Corelight) + + This also works around some of the same warnings. These are known bugs + in GCC 11+ and GCC 13.x. + + * Add zeek-namespaced alias for jthread (Tim Wojtulewicz, Corelight) + + Apple Clang (as of version 17.0.0) does not support jthread unless + you enable experimental libcpp features by defining + _LIBCPP_ENABLE_EXPERIMENTAL or passing -fexperimental_library to + the compiler. Even if you don't do those, our 3rdparty jthread + library fails to build because of a bunch of namespace/naming + collisions. I moved our 3rdparty one to the `nonstd` namespace, and + am using an alias under __APPLE__ to avoid the collisions. + + * Include RequireCXXStd.cmake from main CMakeLists.txt (Tim Wojtulewicz, Corelight) + + * Update submodules to C++20-enabled versions (Tim Wojtulewicz, Corelight) + 8.0.0-dev.631 | 2025-07-10 08:55:39 -0700 * Modify known-services policy script to add storage framework support (Tim Wojtulewicz, Corelight) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7804903fab..1a1aff11a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,8 +90,6 @@ set(ZEEK_ETC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc" set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "Whether to write a JSON compile commands database") -set(ZEEK_CXX_STD cxx_std_17 CACHE STRING "The C++ standard to use.") - set(ZEEK_SANITIZERS "" CACHE STRING "Sanitizers to use when building.") set(CPACK_SOURCE_IGNORE_FILES "" CACHE STRING "Files to be ignored by CPack") @@ -194,7 +192,7 @@ if (MSVC) # 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") + #set(WNOERROR_FLAG "/WX:NO") endif () # Always build binpac in static mode if building on Windows @@ -204,11 +202,26 @@ else () include(GNUInstallDirs) if (BUILD_WITH_WERROR) set(WERROR_FLAG "-Werror") + set(WNOERROR_FLAG "-Wno-error") + + # With versions >=13.0 GCC gained `-Warray-bounds` which reports false + # positives, see e.g., https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111273. + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0) + list(APPEND WERROR_FLAG "-Wno-error=array-bounds") + endif () + + # With versions >=11.0 GCC is returning false positives for -Wrestrict. See + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100366. It's more prevalent + # building with -std=c++20. + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) + list(APPEND WERROR_FLAG "-Wno-error=restrict") + endif () endif () endif () include(cmake/CommonCMakeConfig.cmake) include(cmake/CheckCompilerArch.cmake) +include(cmake/RequireCXXStd.cmake) string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) @@ -237,7 +250,7 @@ set(ZEEK_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") # zeek-plugin-create-package.sh. Needed by ZeekPluginConfig.cmake.in. set(ZEEK_PLUGIN_SCRIPTS_PATH "${PROJECT_SOURCE_DIR}/cmake") -# Our C++17 base target for propagating compiler and linker flags. Note: for +# Our C++ base target for propagating compiler and linker flags. Note: for # now, we only use it for passing library dependencies around. add_library(zeek_internal INTERFACE) add_library(Zeek::Internal ALIAS zeek_internal) @@ -356,7 +369,7 @@ endfunction () find_package(Threads REQUIRED) # Interface library for propagating extra flags and include paths to dynamically -# loaded plugins. Also propagates include paths and C++17 mode on the install +# loaded plugins. Also propagates include paths and c++ standard mode on the install # interface. add_library(zeek_dynamic_plugin_base INTERFACE) target_include_directories( diff --git a/VERSION b/VERSION index 0f84629ded..740dcdc3a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.0-dev.631 +8.0.0-dev.636 diff --git a/auxil/bifcl b/auxil/bifcl index 7f9204a4b2..5947749f78 160000 --- a/auxil/bifcl +++ b/auxil/bifcl @@ -1 +1 @@ -Subproject commit 7f9204a4b294a8cacfff94409b79af2186fe6752 +Subproject commit 5947749f7850b075f11d6a2aaefe7dad4f63cb62 diff --git a/auxil/binpac b/auxil/binpac index 25451ee800..08ae5e0670 160000 --- a/auxil/binpac +++ b/auxil/binpac @@ -1 +1 @@ -Subproject commit 25451ee80040d6a1addc186c3ed03e13ce7d4654 +Subproject commit 08ae5e0670cee913b67dbd6be83adb6f86bd4ce9 diff --git a/auxil/broker b/auxil/broker index 11a6452963..bfaf9e4ca8 160000 --- a/auxil/broker +++ b/auxil/broker @@ -1 +1 @@ -Subproject commit 11a64529637393151763f0a11fe50efdd68926ca +Subproject commit bfaf9e4ca8de7ab05845c96fd3685cd3cca1c850 diff --git a/auxil/gen-zam b/auxil/gen-zam index 0af9a34884..b129f9f497 160000 --- a/auxil/gen-zam +++ b/auxil/gen-zam @@ -1 +1 @@ -Subproject commit 0af9a348847e94c1a35cd026b13adecc40dcbaa1 +Subproject commit b129f9f4977af4405724f869cdff0cd9b3dbddd9 diff --git a/auxil/libunistd b/auxil/libunistd index 27f17e1601..7e3670aa1f 160000 --- a/auxil/libunistd +++ b/auxil/libunistd @@ -1 +1 @@ -Subproject commit 27f17e1601123583272aa7622fe4c7b1eeb715d1 +Subproject commit 7e3670aa1f6ab7623a87ff1e770f7f6b5a1c59f1 diff --git a/auxil/zeekctl b/auxil/zeekctl index a824eedf2f..61d7712b82 160000 --- a/auxil/zeekctl +++ b/auxil/zeekctl @@ -1 +1 @@ -Subproject commit a824eedf2fdd28298f09d96ed10c7c74802dc8e4 +Subproject commit 61d7712b828a593bf7b84f67f3123442d5ab6f12 diff --git a/cmake b/cmake index e2211bc960..53a2d51b25 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit e2211bc960fcd2ff8c50d8649ed4eca0d4a9c35c +Subproject commit 53a2d51b256399813c18e07b47eeb7a73bd03eb7 diff --git a/src/3rdparty b/src/3rdparty index 46ad4968b6..22b2618417 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 46ad4968b63604842cca58c7a18b92e9cbc184c3 +Subproject commit 22b2618417bfb587aa9183e1d7774d7fb5023ccf diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bfceb7a671..a72e084502 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,18 +41,8 @@ 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") - #set(WNOERROR_FLAG "/WX:NO") - endif () else () set(SIGN_COMPARE_FLAG "-Wno-sign-compare") - if (BUILD_WITH_WERROR) - set(WERROR_FLAG "-Werror") - set(WNOERROR_FLAG "-Wno-error") - endif () endif () # Rule parser/scanner diff --git a/src/input/readers/ascii/Ascii.cc b/src/input/readers/ascii/Ascii.cc index 9920b2daa0..444b2a9ffd 100644 --- a/src/input/readers/ascii/Ascii.cc +++ b/src/input/readers/ascii/Ascii.cc @@ -121,15 +121,15 @@ bool Ascii::OpenFile() { fname = Info().source; if ( fname.front() != '/' && ! path_prefix.empty() ) { - string path = path_prefix; - std::size_t last = path.find_last_not_of('/'); + std::size_t last = path_prefix.find_last_not_of('/'); + string path; if ( last == string::npos ) // Nothing but slashes -- weird but ok... path = "/"; else - path.erase(last + 1); + path = path_prefix.substr(0, last + 1); - fname = path + "/" + fname; + fname = util::fmt("%s/%s", path.c_str(), fname.c_str()); } file.open(fname); diff --git a/src/input/readers/binary/Binary.cc b/src/input/readers/binary/Binary.cc index eb87f8d0e8..6e9f92aab4 100644 --- a/src/input/readers/binary/Binary.cc +++ b/src/input/readers/binary/Binary.cc @@ -95,15 +95,15 @@ bool Binary::DoInit(const ReaderInfo& info, int num_fields, const Field* const* // Handle path-prefixing. See similar logic in Ascii::OpenFile(). if ( fname.front() != '/' && ! path_prefix.empty() ) { - string path = path_prefix; - std::size_t last = path.find_last_not_of('/'); + std::size_t last = path_prefix.find_last_not_of('/'); + string path; if ( last == string::npos ) // Nothing but slashes -- weird but ok... path = "/"; else - path.erase(last + 1); + path = path_prefix.substr(0, last + 1); - fname = path + "/" + fname; + fname = util::fmt("%s/%s", path.c_str(), fname.c_str()); } if ( ! OpenInput() ) diff --git a/src/script_opt/ZAM/Profile.cc b/src/script_opt/ZAM/Profile.cc index 60b9affb3e..92c185f2fb 100644 --- a/src/script_opt/ZAM/Profile.cc +++ b/src/script_opt/ZAM/Profile.cc @@ -40,8 +40,10 @@ std::string ZAMLocInfo::Describe(bool include_lines) const { if ( include_lines ) { desc += ";" + func_name + ":" + std::to_string(loc->FirstLine()); - if ( loc->LastLine() > loc->FirstLine() ) - desc += "-" + std::to_string(loc->LastLine()); + if ( loc->LastLine() > loc->FirstLine() ) { + desc.append("-"); + desc.append(std::to_string(loc->LastLine())); + } } } diff --git a/src/storage/Manager.cc b/src/storage/Manager.cc index b511b33b64..0df39b90ca 100644 --- a/src/storage/Manager.cc +++ b/src/storage/Manager.cc @@ -24,7 +24,7 @@ void detail::ExpirationTimer::Dispatch(double t, bool is_expire) { // in the interim. if ( ! expire_running.test_and_set() ) { DBG_LOG(DBG_STORAGE, "Starting new expiration thread"); - storage_mgr->expiration_thread = std::jthread([t]() { storage_mgr->Expire(t); }); + storage_mgr->expiration_thread = zeek::jthread([t]() { storage_mgr->Expire(t); }); } storage_mgr->StartExpirationTimer(); diff --git a/src/storage/Manager.h b/src/storage/Manager.h index cdbc208b04..f918f5b215 100644 --- a/src/storage/Manager.h +++ b/src/storage/Manager.h @@ -3,9 +3,23 @@ #pragma once #include -#include +// Apple's clang has an implementation of std::jthread, but it's still marked +// as experimental. Use the 3rdparty one for that platform and for any other +// that doesn't have it. This could move to util.h if some other code needs +// jthread in the future. +#if defined(__APPLE__) || ! defined(__cpp_lib_jthread) #include "zeek/3rdparty/jthread.hpp" +namespace zeek { +using jthread = nonstd::jthread; +} +#else +#include +namespace zeek { +using jthread = std::jthread; +} +#endif + #include "zeek/Timer.h" #include "zeek/plugin/ComponentManager.h" #include "zeek/storage/Backend.h" @@ -99,7 +113,7 @@ protected: friend class storage::detail::ExpirationTimer; void RunExpireThread(); void StartExpirationTimer(); - std::jthread expiration_thread; + zeek::jthread expiration_thread; friend class storage::OpenResultCallback; void RegisterBackend(BackendPtr backend); diff --git a/src/zeekygen/Target.cc b/src/zeekygen/Target.cc index 1f24149bd9..a9135a4e5b 100644 --- a/src/zeekygen/Target.cc +++ b/src/zeekygen/Target.cc @@ -368,7 +368,9 @@ void PackageTarget::DoGenerate() const { for ( const auto& [pkg, info_vec] : pkg_manifest ) { string header = util::fmt("Package: %s", pkg->Name().c_str()); - header += "\n" + string(header.size(), '='); + auto header_size = header.size(); + header.append("\n"); + header.append(string(header_size, '=')); fprintf(file.f, "%s\n\n", header.c_str());