-
Notifications
You must be signed in to change notification settings - Fork 1.9k
cmake: kafka: enable zstd compression using bundled library #11726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,51 @@ if (FLB_SYSTEM_MACOS) | |
| FLB_OPTION(WITH_CURL Off) | ||
| endif() | ||
|
|
||
| # Enable zstd compression for librdkafka using the library already resolved | ||
| # by the top-level zstd detection block (LIBZSTD_LIBRARIES is set for all | ||
| # cases: bundled, system CMake config, and system pkg-config fallback). | ||
| if(LIBZSTD_LIBRARIES) | ||
| if(TARGET libzstd_static) | ||
| # Bundled: force-inject vars — librdkafka's find_package(ZSTD) cannot | ||
| # discover an in-tree target on its own. | ||
| set(ZSTD_FOUND TRUE CACHE BOOL "" FORCE) | ||
| set(ZSTD_INCLUDE_DIR "${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_ZSTD}/lib" CACHE PATH "" FORCE) | ||
| set(ZSTD_LIBRARY_DEBUG libzstd_static CACHE STRING "" FORCE) | ||
| set(ZSTD_LIBRARY_RELEASE libzstd_static CACHE STRING "" FORCE) | ||
| set(ZSTD_LIBRARY libzstd_static CACHE STRING "" FORCE) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Forcing Useful? React with 👍 / 👎. |
||
| FLB_OPTION(WITH_ZSTD ON) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Setting Useful? React with 👍 / 👎. |
||
| set(FLB_KAFKA_ZSTD_SOURCE "bundled") | ||
| else() | ||
| # System: clear stale bundled-sentinel entries and WITH_ZSTD so librdkafka | ||
| # re-runs find_package(ZSTD) fresh and its option() sets its own default. | ||
| # Preserve explicit caller overrides such as -DZSTD_LIBRARY=/custom/path. | ||
| if(ZSTD_LIBRARY STREQUAL "libzstd_static") | ||
| unset(ZSTD_FOUND CACHE) | ||
| unset(ZSTD_INCLUDE_DIR CACHE) | ||
|
Comment on lines
+98
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When zstd is discovered through Fluent Bit's pkg-config fallback ( Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When zstd is found via pkg-config it is present in standard system paths that librdkafka's find_package(ZSTD) will also search. If the two diverge it indicates a non-standard prefix where the caller should supply CMAKE_PREFIX_PATH or -DZSTD_ROOT; silently forwarding pkg-config results into librdkafka's find variables would reintroduce the stale-cache issues this change was designed to avoid. |
||
| unset(ZSTD_LIBRARY CACHE) | ||
| unset(ZSTD_LIBRARY_DEBUG CACHE) | ||
| unset(ZSTD_LIBRARY_RELEASE CACHE) | ||
| unset(WITH_ZSTD CACHE) | ||
| endif() | ||
| set(FLB_KAFKA_ZSTD_SOURCE "system") | ||
| endif() | ||
| else() | ||
| # FLB didn't find zstd. Clear stale bundled entries so librdkafka's | ||
| # find_package/option() runs fresh and defaults to OFF. | ||
| # Preserve user-supplied custom paths (ZSTD_LIBRARY != sentinel). | ||
| if(ZSTD_LIBRARY STREQUAL "libzstd_static") | ||
| unset(ZSTD_FOUND CACHE) | ||
| unset(ZSTD_INCLUDE_DIR CACHE) | ||
| unset(ZSTD_LIBRARY CACHE) | ||
| unset(ZSTD_LIBRARY_DEBUG CACHE) | ||
| unset(ZSTD_LIBRARY_RELEASE CACHE) | ||
| unset(WITH_ZSTD CACHE) | ||
| elseif(NOT ZSTD_LIBRARY) | ||
| unset(WITH_ZSTD CACHE) | ||
| endif() | ||
| set(FLB_KAFKA_ZSTD_SOURCE "disabled") | ||
| endif() | ||
|
|
||
| include_directories(${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RDKAFKA}/src/) | ||
|
|
||
| add_subdirectory(${FLB_PATH_LIB_RDKAFKA} EXCLUDE_FROM_ALL) | ||
|
|
@@ -88,4 +133,5 @@ message(STATUS "=== Kafka Feature Summary ===") | |
| message(STATUS "SASL Auth: ${FLB_SASL_ENABLED}") | ||
| message(STATUS "OAuth Bearer: ${FLB_SASL_OAUTHBEARER_ENABLED}") | ||
| message(STATUS "MSK IAM: ${FLB_KAFKA_MSK_IAM_ENABLED}") | ||
| message(STATUS "ZSTD: ${FLB_KAFKA_ZSTD_SOURCE}") | ||
| message(STATUS "===============================") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bundled branch force-writes
ZSTD_*cache entries, but the system branch never unsets or updates them. On reconfigure in the same build directory (e.g., switching from bundled toFLB_PREFER_SYSTEM_LIB_ZSTD=ON), stalelibzstd_staticcache values are reused by librdkafka, so configuration can continue to report/use bundled linkage while the feature summary sayssystem. This cache contamination is introduced by the forced cache writes and should be cleaned up in the non-bundled path.Useful? React with 👍 / 👎.