diff --git a/CMakeLists.txt b/CMakeLists.txt index 2db15a0ae7..915a0a55c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -759,6 +759,9 @@ if ( NOT BINARY_PACKAGING_MODE ) endif () string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zeek-version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/zeek-version.h) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zeek-version.h DESTINATION include/zeek) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zeek-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/zeek-config.h) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/NEWS b/NEWS index 0104e6a89f..528467f4ab 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,25 @@ release. For an exhaustive list of changes, see the ``CHANGES`` file Zeek 6.0.0 ========== +Breaking Changes +---------------- + +- The zeek/zeek-config.h header does not provide the macros ZEEK_VERSION and + ZEEK_VERSION_NUMBER anymore when compiling builtin plugins. This may affect + external plugins included via the configure flag ``--include-plugins`` + referencing these macros. A suggested update for these plugins is adding + the following snippet: + + #if __has_include("zeek/zeek-version.h") + #include "zeek/zeek-version.h" + #endif + + External plugins that are built out-of-tree, e.g. via ``zkg`` are not + affected by this change. + + The main motivation is improved ccache effectiveness for speedier CI and + development builds whenever a VERSION bump happens. + New Functionality ----------------- diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index c026bc9b3d..85b00e8060 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -2,8 +2,6 @@ #pragma once -#include "zeek/zeek-config.h" - #include #include #include @@ -13,9 +11,15 @@ #include "zeek/ZeekArgs.h" #include "zeek/logging/WriterBackend.h" +// Avoid ccache busting of Plugin.h for internal plugins by +// only including zeek/zeek-version.h if we're building an +// external plugin. +#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD +#include "zeek/zeek-version.h" // Remove the BRO define in v6.1. #define BRO_PLUGIN_BRO_VERSION ZEEK_VERSION_FUNCTION #define ZEEK_PLUGIN_ZEEK_VERSION ZEEK_VERSION_FUNCTION +#endif namespace zeek::threading { @@ -126,8 +130,13 @@ public: #endif inline Configuration() __attribute__((always_inline)) { +// Only bake in a ZEEK_PLUGIN_ZEEK_VERSION reference into external +// plugins. The internal ones are in the same binary so the runtime +// link check shouldn't be needed and we can avoid ccache busting. +#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD bro_version = ZEEK_PLUGIN_ZEEK_VERSION; zeek_version = ZEEK_PLUGIN_ZEEK_VERSION; +#endif } #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/src/version.c.in b/src/version.c.in index b49865dd30..e7508c8415 100644 --- a/src/version.c.in +++ b/src/version.c.in @@ -1,5 +1,5 @@ -#include "zeek/zeek-config.h" +#include "zeek/zeek-version.h" char version[] = "@VERSION@"; diff --git a/zeek-config.h.in b/zeek-config.h.in index 3e5f0bfe41..eb5fa14d1b 100644 --- a/zeek-config.h.in +++ b/zeek-config.h.in @@ -141,14 +141,6 @@ /* Use the sqlite reader/writer. */ #cmakedefine USE_SQLITE -/* Version number of package */ -#define VERSION "@VERSION@" - -// Zeek version number. -// This is the result of (major * 10000 + minor * 100 + patch) -// For example, 3.1.2 becomes 30102. -#define ZEEK_VERSION_NUMBER @ZEEK_VERSION_NUMBER@ - /* whether words are stored with the most significant byte first */ #cmakedefine WORDS_BIGENDIAN @@ -251,19 +243,18 @@ /* String with extension of dynamic libraries (e.g., ".so") */ #define DYNAMIC_PLUGIN_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@" -/* True if we're building outside of the main Zeek source code tree. */ +/* Set if we're building outside of the main Zeek source code tree. */ #ifndef ZEEK_PLUGIN_INTERNAL_BUILD -#define ZEEK_PLUGIN_INTERNAL_BUILD @ZEEK_PLUGIN_INTERNAL_BUILD@ +#define ZEEK_PLUGIN_INTERNAL_BUILD true +#else +// Backwards compat for external plugins, include the version +// identifiers through zeek/zeek-version.h. +#if ! ZEEK_PLUGIN_INTERNAL_BUILD +#include "zeek/zeek-version.h" #endif - -/* A C function that has the Zeek version encoded into its name. */ -#define ZEEK_VERSION_FUNCTION zeek_version_@VERSION_C_IDENT@ -#ifdef __cplusplus -extern "C" { -#endif -extern const char* ZEEK_VERSION_FUNCTION(); -#ifdef __cplusplus -} +// +// Not sure we can ever deprecate this without changing +// the names. #endif // GCC uses __SANITIZE_ADDRESS__, Clang uses __has_feature diff --git a/zeek-version.h.in b/zeek-version.h.in new file mode 100644 index 0000000000..30b0c914ba --- /dev/null +++ b/zeek-version.h.in @@ -0,0 +1,19 @@ +#pragma once + +/* Version number of package */ +#define VERSION "@VERSION@" + +// Zeek version number. +// This is the result of (major * 10000 + minor * 100 + patch) +// For example, 3.1.2 becomes 30102. +#define ZEEK_VERSION_NUMBER @ZEEK_VERSION_NUMBER@ + +/* A C function that has the Zeek version encoded into its name. */ +#define ZEEK_VERSION_FUNCTION zeek_version_@VERSION_C_IDENT@ +#ifdef __cplusplus +extern "C" { +#endif +extern const char* ZEEK_VERSION_FUNCTION(); +#ifdef __cplusplus +} +#endif