-
Notifications
You must be signed in to change notification settings - Fork 1.8k
build: workflows: Add a rules for checking incompatible types strictly #10655
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?
Conversation
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.
We should update to Ubuntu 24 soon really as well, it is the latest one so 22 will go.
I recommend renaming the new option for clarity to |
Sounds good. I'll rename it later. |
9d7cc2d
to
2e94779
Compare
Signed-off-by: Hiroshi Hatake <[email protected]>
0d7a9ea
to
a709772
Compare
WalkthroughAdds 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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]>
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
a709772
to
12b7529
Compare
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.
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.
📒 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.
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:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
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
Chores