Skip to content

Conversation

cosmo0920
Copy link
Contributor

@cosmo0920 cosmo0920 commented Jul 28, 2025

This is because this behavior is default since gcc 14 or later.
But our CI is still using ubuntu-22.04 as a base testing workers.
So, we need to implement an additional task for denying incompatible
types for pointer operations.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Tests

    • Expanded CI unit test matrix to cover builds with strict pointer-type enforcement using clang, ensuring this configuration is validated without affecting default clang runs.
  • Chores

    • Introduced an opt-in build setting to treat incompatible pointer types as errors, enhancing type-safety for those who enable it.
    • Tuned AppleClang warning behavior to avoid qualifier-discard noise while preserving strict pointer-type checks when the setting is enabled.

Copy link
Contributor

@patrick-stephens patrick-stephens left a comment

Choose a reason for hiding this comment

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

We should update to Ubuntu 24 soon really as well, it is the latest one so 22 will go.

@edsiper
Copy link
Member

edsiper commented Jul 29, 2025

I recommend renaming the new option for clarity to FLB_COMPILER_STRICT_POINTER_TYPES

@cosmo0920
Copy link
Contributor Author

I recommend renaming the new option for clarity to FLB_COMPILER_STRICT_POINTER_TYPES

Sounds good. I'll rename it later.

@cosmo0920 cosmo0920 force-pushed the cosmo0920-deny-incompatible-types branch from 9d7cc2d to 2e94779 Compare July 29, 2025 23:15
@cosmo0920 cosmo0920 force-pushed the cosmo0920-deny-incompatible-types branch from 0d7a9ea to a709772 Compare September 5, 2025 11:11
Copy link

coderabbitai bot commented Sep 5, 2025

Walkthrough

Adds a CMake option to enforce incompatible pointer type errors and updates the CI matrix to run a dedicated clang job with this option enabled, while excluding it from default clang runs.

Changes

Cohort / File(s) Summary of changes
CI Workflow
.github/workflows/unit-tests.yaml
Adds -DFLB_COMPILER_STRICT_POINTER_TYPES=On to matrix options; introduces a clang-specific matrix entry to run with this flag; adds an exclude rule so default clang runs omit this pairing.
Build Configuration (CMake)
CMakeLists.txt
Adds option FLB_COMPILER_STRICT_POINTER_TYPES (default Off). When On: applies -Werror=incompatible-pointer-types for GNU/Clang/AppleClang; for AppleClang also sets -Wno-incompatible-pointer-types-discards-qualifiers.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant GH as GitHub Actions
    participant UT as Unit Tests Job
    participant CMake as CMake Configure/Build
    participant Test as Test Runner

    Dev->>GH: Open/Update PR
    GH->>UT: Trigger matrix
    rect rgba(222,235,247,0.5)
      note over UT: Matrix variants
      UT->>UT: {compiler ∈ [gcc, clang]} × {options ∋ strict-pointer-types}
      UT->>UT: Exclude default clang+strict combo
      UT->>UT: Add dedicated clang+strict job
    end
    UT->>CMake: Configure with -DFLB_COMPILER_STRICT_POINTER_TYPES=On (clang-only job)
    CMake-->>UT: Build artifacts
    UT->>Test: Run unit tests
    Test-->>GH: Report results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

ok-package-test

Suggested reviewers

  • niedbalski
  • fujimotos
  • celalettin1286
  • edsiper

Poem

I twitch my whiskers at pointer types,
Flags set high for stricter gripes.
Clang now checks with earnest glare,
CMake flips the cautious snare.
Hoppity hops through tests I go,
Carrots green when statuses glow. 🥕✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cosmo0920-deny-incompatible-types

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cosmo0920 cosmo0920 changed the title build: workflows: Add a rules for denying incompatible types build: workflows: Add a rules for checking incompatible types structly Sep 5, 2025
@cosmo0920 cosmo0920 changed the title build: workflows: Add a rules for checking incompatible types structly build: workflows: Add a rules for checking incompatible types strictly Sep 5, 2025
This is because this behavior is default since gcc 14 or later.
But our CI is still using ubuntu-22.04 as a base testing workers.
So, we need to implement an additional task for denying incompatible
types for pointer operations.

Signed-off-by: Hiroshi Hatake <[email protected]>
@cosmo0920 cosmo0920 force-pushed the cosmo0920-deny-incompatible-types branch from a709772 to 12b7529 Compare September 5, 2025 11:14
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: 0

🧹 Nitpick comments (3)
.github/workflows/unit-tests.yaml (2)

56-56: Add macOS coverage for strict pointer types.

You’re only exercising the flag on Ubuntu. Given the AppleClang-specific handling in CMake, add a macOS matrix entry to catch AppleClang-only issues.

Apply:

       matrix:
         flb_option:
           - "-DFLB_JEMALLOC=Off"
           - "-DFLB_SANITIZE_MEMORY=On"
           - "-DFLB_SANITIZE_THREAD=On"
+          - "-DFLB_COMPILER_STRICT_POINTER_TYPES=On"

75-78: Clang path for strict-pointer-types is excluded; add an explicit include to still run it.

Right now clang + strict-pointer-types never runs in this job. If that’s intentional for the cross product, explicitly re-add it via include to ensure we test clang with this flag.

Apply:

       matrix:
         flb_option:
           - "-DFLB_JEMALLOC=On"
           ...
           - "-DFLB_COMPILER_STRICT_POINTER_TYPES=On"
         cmake_version:
           - "3.31.6"
         compiler:
           - gcc:
             cc: gcc
             cxx: g++
           - clang:
             cc: clang
             cxx: clang++
+        include:
+          - flb_option: "-DFLB_COMPILER_STRICT_POINTER_TYPES=On"
+            compiler:
+              cc: clang
+              cxx: clang++
         exclude:
           - flb_option: "-DFLB_COVERAGE=On"
             compiler:
               cc: clang
               cxx: clang++
           - flb_option: "-DFLB_ARROW=On"
             compiler:
               cc: clang
               cxx: clang++
           - flb_option: "-DFLB_COMPILER_STRICT_POINTER_TYPES=On"
             compiler:
               cc: clang
               cxx: clang++
CMakeLists.txt (1)

450-459: Scope flags to C-only to avoid leaking unknown-warning options into C++.

add_compile_options applies to all languages; use generator expressions to constrain to C to prevent noisy “unknown warning option” from C++ compilations.

Apply:

-if(FLB_COMPILER_STRICT_POINTER_TYPES)
-  if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
-    add_compile_options(-Werror=incompatible-pointer-types)
-  endif()
-  # Currently, AppleClang has more struct rules when using -Werror=incompatible-pointer-types.
-  # We still permit to discarding const qualifiers warnings.
-  if(CMAKE_C_COMPILER_ID MATCHES "AppleClang")
-    add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers)
-  endif()
-endif()
+if(FLB_COMPILER_STRICT_POINTER_TYPES)
+  if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
+    add_compile_options($<$<COMPILE_LANGUAGE:C>:-Werror=incompatible-pointer-types>)
+  endif()
+  # AppleClang: allow discarding const-qualifier diagnostics without failing the build.
+  if(CMAKE_C_COMPILER_ID MATCHES "AppleClang")
+    add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-incompatible-pointer-types-discards-qualifiers>)
+    # Alternative (keeps warning visible): -Wno-error=incompatible-pointer-types-discards-qualifiers
+  endif()
+endif()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c01c62c and 12b7529.

📒 Files selected for processing (2)
  • .github/workflows/unit-tests.yaml (2 hunks)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-31T12:46:11.940Z
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 CMakeLists.txt, the system library preference flags are defined as FLB_PREFER_SYSTEM_LIB_ZSTD and FLB_PREFER_SYSTEM_LIB_KAFKA with the FLB_ prefix.

Applied to files:

  • CMakeLists.txt
  • .github/workflows/unit-tests.yaml
⏰ 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). (21)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 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 (-DSANITIZE_ADDRESS=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 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_SIMD=Off, 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 (-DFLB_SIMD=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_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 (-DSANITIZE_UNDEFINED=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 (-DSANITIZE_ADDRESS=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_JEMALLOC=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=Off, 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 (-DFLB_JEMALLOC=On, 3.31.6, clang, clang++)
  • GitHub Check: pr-compile-centos-7
🔇 Additional comments (1)
CMakeLists.txt (1)

161-161: Option name LGTM and consistent with FLB_ flags.*

Clear name and default. No issues.

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.

3 participants