Skip to content

Conversation

@mabrarov
Copy link
Contributor

@mabrarov mabrarov commented Jan 26, 2026

Summary

  • Fixed C/C++ compiler options in CMake project especially when MSVC is used (e.g. fixed passing preprocessor definitions required for Windows containers failing to build #10158).
  • Fixed (formatting, build command) development guide for Windows.
  • Fixed support of "Visual Studio" CMake Generators - refer to Windows containers failing to build #10158.
    Note: multi-config CMake Generators (like "Visual Studio" ones) can still have issues due to Fluent Bit CMake project doesn't honor and doesn't support the build type(s) specified when CMake generates native build system project - e.g. CMAKE_BUILD_TYPE passed through command line and CMAKE_CONFIGURATION_TYPES. Support of multi-config CMake Generators can require usage of CMake generator expressions everywhere build-config specific compiler / linker options are added / modified, can require revisiting of the way linked libraries are specified, e.g. they should not use -l option with hard-coded name of static library file, because the name of library file can depend on build configuration on Windows - e.g. libcrypto.lib for Release and RelWithDebInfo builds with /MT compiler option (static release MS C/C++ runtime) vs libcryptod.lib for Debug build with /MTd compiler option (static debug MS C/C++ runtime).
  • Fixed parallel build of Fluent Bit when building docker image for Windows containers.
  • Fixed "negative coverage" error when collecting test coverage with coverage profiled build.

Testing

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

  • [N/A] Example configuration file for the change.
  • [N/A] Debug log output from testing the change.
  • Attached Valgrind output that shows no leaks or memory corruption was found - refer to flb_run_code_analysis.log for the output of command
    TEST_PRESET=valgrind SKIP_TESTS='flb-rt-out_td flb-it-network' ./run_code_analysis.sh
  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature.

Backporting

  • [N/A] 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

  • Build & Infrastructure

    • Switched Windows builds to Ninja toolchain and adjusted build invocation for consistent builds.
    • Introduced deferred C++ compiler/linker flag holders to apply flags only when C++ is enabled.
    • Updated MSVC handling: enable UTF‑8, adjust static runtime behavior with per‑configuration handling, and make debug option disabled for MSVC builds.
    • Adjusted ARM/FreeBSD linker-flag handling.
  • Documentation

    • Updated Windows build instructions to explicitly build the Release configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

Introduces delayed-extension variables for C++ compile/link flags, applies them when C++ is enabled; adjusts MSVC runtime handling to prefer static CRT and enables /utf-8; switches Windows Docker build to use Ninja; updates Windows build invocation in the developer guide.

Changes

Cohort / File(s) Summary
Top-level CMake orchestrator
CMakeLists.txt
Adds FLB_EXTRA_CMAKE_CXX_FLAGS and FLB_EXTRA_CMAKE_CXX_LINK_FLAGS (initialized empty) and a delayed-extension workflow to merge them into CMAKE_CXX_FLAGS/CMAKE_CXX_LINK_FLAGS when C++ is enabled; MSVC-specific handling moved to delayed path; MK_DEBUG now ON only when not MSVC; per-config /utf-8 and /MT handling introduced.
Onigmo MSVC CMake tweaks
lib/onigmo/CMakeLists.txt
Adjusts MSVC runtime selection to prefer MT/MTd (uses CMAKE_MSVC_RUNTIME_LIBRARY when available), converts CFLAGS to MT variants, adds /utf-8, removes forced CMAKE_BUILD_TYPE None and earlier global /MT additions.
Windows Docker build image
dockerfiles/Dockerfile.windows
Adds Ninja installation (NINJA_HOME, download/extract, PATH persistence) and switches builder stage to Ninja generator; removes explicit -DCMAKE_BUILD_TYPE=Release and NMake-specific build invocation.
Developer guide (Windows build)
DEVELOPER_GUIDE.md
Changes Windows build command to include --config Release in cmake --build and adjusts code block formatting.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • edsiper
  • cosmo0920
  • niedbalski
  • patrick-stephens
  • fujimotos
  • celalettin1286

Poem

🐰 I nibbled flags in twilight code,

Delayed my hops till C++ showed,
Ninja danced across the Windows plain,
UTF‑8 hummed a softer refrain,
Static threads stitched builds again.

🚥 Pre-merge checks | ✅ 3
✅ 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 'build: CMake project fixes for MS Visual C++ compiler' directly and clearly summarizes the main change—CMake build system fixes for MSVC compatibility. It accurately reflects the primary focus of the changeset across CMakeLists.txt, Dockerfile.windows, developer guide, and onigmo CMakeLists.txt.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

@mabrarov mabrarov marked this pull request as ready for review January 26, 2026 20:05
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: 2

🤖 Fix all issues with AI agents
In `@CMakeLists.txt`:
- Around line 57-63: The unconditional set of FLB_EXTRA_CMAKE_CXX_FLAGS and
FLB_EXTRA_CMAKE_CXX_LINK_FLAGS is shadowing command-line -D overrides; change
the initialization so caller-provided values are preserved by either (a)
wrapping the current set calls with if(NOT DEFINED FLB_EXTRA_CMAKE_CXX_FLAGS) /
if(NOT DEFINED FLB_EXTRA_CMAKE_CXX_LINK_FLAGS) or (b) declare them as cache
variables (e.g., set(FLB_EXTRA_CMAKE_CXX_FLAGS "" CACHE STRING "extra CXX
flags") and set(FLB_EXTRA_CMAKE_CXX_LINK_FLAGS "" CACHE STRING "extra CXX link
flags")) so later appends (e.g., where FLB_EXTRA_CMAKE_CXX_LINK_FLAGS is
extended with -latomic) will honor -D overrides; update the existing set(...)
lines around FLB_EXTRA_CMAKE_CXX_FLAGS and FLB_EXTRA_CMAKE_CXX_LINK_FLAGS
accordingly.

In `@dockerfiles/Dockerfile.windows`:
- Around line 86-104: The RUN block that downloads Ninja (variables
NINJA_VERSION, NINJA_URL, NINJA_HOME and local vars $ninja_dist_name,
$ninja_dist, $ninja_download_url) lacks SHA256 validation; after
Invoke-WebRequest and before Expand-Archive compute the SHA256 of ${ninja_dist}
with Get-FileHash -Algorithm SHA256 and compare it against the known digest
07fc8261b42b20e71d1720b39068c2e14ffcee6396b76fb7a795fb460b78dc65, and if they
differ throw an error/exit the build (e.g. throw or [Environment]::Exit(1)) to
prevent extraction; keep the rest of the flow (Remove-Item, Expand-Archive, PATH
and SetEnvironmentVariable) unchanged.

@mabrarov
Copy link
Contributor Author

This PR is ready for review. The failed CI jobs seem to be failing because of internal infrastructure issues now (previously it was this PR issue - refer to #11397 (comment)).

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