Skip to content

Conversation

@ThomasDevoogdt
Copy link
Contributor

@ThomasDevoogdt ThomasDevoogdt commented May 16, 2025

Upstream: confluentinc/librdkafka#4366

Summary by CodeRabbit

  • Bug Fixes

    • Builds now succeed without a C++ compiler; C++ examples and tests are skipped when a C++ toolchain isn’t available, reducing failures in minimal environments.
  • Chores

    • Updated PR compile checks to simplify dependencies by removing an external Kafka library installation.
    • Adjusted build preferences to no longer favor a system-provided Kafka library while still preferring a system-provided Zstandard library.
    • Overall build process is more resilient across diverse environments.

ThomasDevoogdt and others added 2 commits October 4, 2025 09:09
This reverts commit 32fc9dd.

Not needed anymore since librdkafka has been fixed.

Signed-off-by: Thomas Devoogdt <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Walkthrough

The workflow stops installing system librdkafka and removes the CMake flag preferring system Kafka. The vendored librdkafka CMake adds C/C++ language detection and conditionally builds C++ components and examples only when a C++ compiler is available.

Changes

Cohort / File(s) Summary
CI workflow adjustments
.github/workflows/pr-compile-check.yaml
Removed installation of librdkafka-dev and -DFLB_PREFER_SYSTEM_LIB_KAFKA=ON; retained -DFLB_PREFER_SYSTEM_LIB_ZSTD=ON.
Vendored librdkafka core CMake
lib/librdkafka-2.10.1/CMakeLists.txt
Declared project with LANGUAGES C; added CXX detection via CheckLanguage; enabled CXX if present; gated C++ tests and src-cpp subdirectory behind CXX checks.
Vendored librdkafka examples CMake
lib/librdkafka-2.10.1/examples/CMakeLists.txt
Wrapped C++ example targets (producer_cpp, rdkafka_*_cpp, openssl_engine_example_cpp, kafkatest_verifiable_client on non-Windows) in if(CMAKE_CXX_COMPILER) blocks.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Developer/CI
    participant CMake as CMake Config
    participant Toolchain as Toolchain
    participant Targets as Build Targets

    Dev->>CMake: Configure project
    CMake->>Toolchain: Check C compiler
    Toolchain-->>CMake: C found
    CMake->>Toolchain: Check C++ compiler
    alt C++ compiler available
        Toolchain-->>CMake: C++ found
        CMake->>Targets: Enable C and C++\nAdd src and src-cpp\nEnable C++ examples/tests
    else No C++ compiler
        Toolchain-->>CMake: C++ not found
        CMake->>Targets: Enable C only\nAdd src\nSkip src-cpp/examples/tests (C++)
        Note over CMake,Targets: C-only build proceeds
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • leonardo-albertovich
  • edsiper
  • niedbalski
  • patrick-stephens
  • koleini
  • fujimotos
  • celalettin1286

Poem

Thump-thump go my paws on the CI trail,
Snipping C++ where compilers fail.
C hops along; Kafka still sings—
Examples hide till CXX springs.
Burrow built clean, no system brew,
Zstd’s in stash; we’re good. Woo-hoo! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the main change of making librdkafka build require only a C compiler by removing C++ dependencies and related CMake flags. It directly reflects the updates in both the CI workflow and CMakeLists that conditionally skip C++ components. The phrasing is specific enough for teammates to understand the primary intent without extraneous details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/librdkafka-2.10.1/CMakeLists.txt (1)

304-307: Also gate tests on actual C++ availability

Even without the option() call, a cache entry like -DRDKAFKA_BUILD_TESTS=ON keeps this block true. On hosts lacking a usable C++ toolchain (the exact case this PR targets), we would still dive into add_subdirectory(tests) and the build fails. Please guard this block with the same CMAKE_CXX_COMPILER check used for src-cpp, e.g.:

-if(RDKAFKA_BUILD_TESTS)
+if(CMAKE_CXX_COMPILER AND RDKAFKA_BUILD_TESTS)
   enable_testing()
   add_subdirectory(tests)
 endif()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9593e and 0a124d4.

📒 Files selected for processing (3)
  • .github/workflows/pr-compile-check.yaml (2 hunks)
  • lib/librdkafka-2.10.1/CMakeLists.txt (3 hunks)
  • lib/librdkafka-2.10.1/examples/CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ThomasDevoogdt
PR: fluent/fluent-bit#9277
File: .github/workflows/pr-compile-check.yaml:147-151
Timestamp: 2025-08-31T12:46:11.940Z
Learning: In fluent-bit, the correct CMake flag for using system librdkafka is `FLB_PREFER_SYSTEM_LIB_KAFKA=ON`.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_ARROW=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_COVERAGE=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, clang, clang++)

Comment on lines +9 to +15
include(CheckLanguage)
check_language(CXX)
if(CMAKE_CXX_COMPILER)
enable_language(CXX)
else()
message(STATUS "C++ compiler not found, skipping C++ support")
endif()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Handle bogus CXX values before calling enable_language

When CXX is preset to something non-working (e.g. our no-C++ workflow exports /bin/false), check_language(CXX) still leaves CMAKE_CXX_COMPILER pointing at that path instead of *-NOTFOUND. The current if (CMAKE_CXX_COMPILER) conditional therefore fires and enable_language(CXX) aborts configuration, defeating the “C-only” fallback we’re trying to enable. Please tighten the guard so we only enable C++ when CMAKE_CXX_COMPILER is both defined and not *-NOTFOUND. One way is:

-check_language(CXX)
-if(CMAKE_CXX_COMPILER)
+check_language(CXX)
+if(CMAKE_CXX_COMPILER AND NOT CMAKE_CXX_COMPILER MATCHES "-NOTFOUND$")
   enable_language(CXX)
 else()
   message(STATUS "C++ compiler not found, skipping C++ support")
 endif()
🤖 Prompt for AI Agents
In lib/librdkafka-2.10.1/CMakeLists.txt around lines 9-15, the current guard
uses if(CMAKE_CXX_COMPILER) which can be true for bogus values like /bin/false
left by check_language(CXX), causing enable_language(CXX) to abort; change the
conditional to only enable C++ when the compiler is both defined and not a
NOTFOUND marker, e.g. use if(DEFINED CMAKE_CXX_COMPILER AND NOT
CMAKE_CXX_COMPILER MATCHES "-NOTFOUND$") then enable_language(CXX) else emit the
existing status message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant