mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge branch 'topic/timw/c++20'
* topic/timw/c++20: Reduce some false-positive warnings from GCC to warnings with -Werror Add zeek-namespaced alias for jthread Include RequireCXXStd.cmake from main CMakeLists.txt Update submodules to C++20-enabled versions
This commit is contained in:
commit
1e55543e86
18 changed files with 80 additions and 38 deletions
21
CHANGES
21
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)
|
||||
|
|
|
@ -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(
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
8.0.0-dev.631
|
||||
8.0.0-dev.636
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7f9204a4b294a8cacfff94409b79af2186fe6752
|
||||
Subproject commit 5947749f7850b075f11d6a2aaefe7dad4f63cb62
|
|
@ -1 +1 @@
|
|||
Subproject commit 25451ee80040d6a1addc186c3ed03e13ce7d4654
|
||||
Subproject commit 08ae5e0670cee913b67dbd6be83adb6f86bd4ce9
|
|
@ -1 +1 @@
|
|||
Subproject commit 11a64529637393151763f0a11fe50efdd68926ca
|
||||
Subproject commit bfaf9e4ca8de7ab05845c96fd3685cd3cca1c850
|
|
@ -1 +1 @@
|
|||
Subproject commit 0af9a348847e94c1a35cd026b13adecc40dcbaa1
|
||||
Subproject commit b129f9f4977af4405724f869cdff0cd9b3dbddd9
|
|
@ -1 +1 @@
|
|||
Subproject commit 27f17e1601123583272aa7622fe4c7b1eeb715d1
|
||||
Subproject commit 7e3670aa1f6ab7623a87ff1e770f7f6b5a1c59f1
|
|
@ -1 +1 @@
|
|||
Subproject commit a824eedf2fdd28298f09d96ed10c7c74802dc8e4
|
||||
Subproject commit 61d7712b828a593bf7b84f67f3123442d5ab6f12
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
|||
Subproject commit e2211bc960fcd2ff8c50d8649ed4eca0d4a9c35c
|
||||
Subproject commit 53a2d51b256399813c18e07b47eeb7a73bd03eb7
|
|
@ -1 +1 @@
|
|||
Subproject commit 46ad4968b63604842cca58c7a18b92e9cbc184c3
|
||||
Subproject commit 22b2618417bfb587aa9183e1d7774d7fb5023ccf
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() )
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -3,9 +3,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
// 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 <thread>
|
||||
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);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue