Skip to content

build: CMake project fixes for MS Visual C++ compiler#11397

Open
mabrarov wants to merge 8 commits intofluent:masterfrom
mabrarov:feature/cmake_msvc
Open

build: CMake project fixes for MS Visual C++ compiler#11397
mabrarov wants to merge 8 commits intofluent:masterfrom
mabrarov:feature/cmake_msvc

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). It makes possible debugging of (Windows build of) Fluent Bit / tests on Windows.
  • 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

    • Windows build switched to Ninja; build invocation updated.
    • Added a delayed-extension mechanism for C++ compiler/linker flags, applied only when C++ is enabled.
    • Improved MSVC handling: UTF‑8 source encoding enabled, static-runtime selection moved to per-configuration logic, and MSVC-specific debug option disabled.
    • Coverage and platform-specific linker-flag handling improved; MPack tracking explicitly disabled.
  • Documentation

    • Windows build docs updated with vcpkg integration and revised build commands.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

Adds FLB_EXTRA_CMAKE_CXX_FLAGS and FLB_EXTRA_CMAKE_CXX_LINK_FLAGS for delayed C++ flag/linker-flag extension, moves MSVC runtime and /utf-8 handling into a per-config delayed workflow, switches Windows builder to Ninja, and updates developer guide build examples and Windows Dockerfile.

Changes

Cohort / File(s) Summary
Top-level CMake orchestrator
CMakeLists.txt
Introduces FLB_EXTRA_CMAKE_CXX_FLAGS and FLB_EXTRA_CMAKE_CXX_LINK_FLAGS (empty defaults) and a delayed-extension workflow to merge them when C++ is enabled; moves MSVC per-config /MT handling, sets /utf-8, adjusts /Zi/coverage flags, and guards MK_DEBUG with NOT MSVC.
Onigmo MSVC CMake tweaks
lib/onigmo/CMakeLists.txt
Converts global /MT to per-config MSVC runtime handling (uses CMAKE_MSVC_RUNTIME_LIBRARY when available), applies /utf-8, removes hard-coded CMAKE_BUILD_TYPE None, and updates per-config C flags replacements.
Windows Docker build image
dockerfiles/Dockerfile.windows
Adds Ninja installation (NINJA_HOME, download/extract, PATH persistence), switches builder stage to Ninja generator, and removes NMake/explicit -DCMAKE_BUILD_TYPE=Release usage.
Developer guide (Windows build & vcpkg)
DEVELOPER_GUIDE.md
Updates build example to cmake --build . --config Release --parallel 4 --clean-first, adds vcpkg manifest/integration guidance, and adjusts Windows Flex/Bison and formatting for clarity.
Coverage / platform notes & MPack flags
CMakeLists.txt (coverage/Unicode/wasm/armv7l/FreeBSD blocks), lib/onigmo/...
Adds delayed-extension markers for CXX/CXX_LINK flags on Unicode/wasm/armv7l/FreeBSD paths; adds -fprofile-update=atomic where appropriate and defines MPACK_READ_TRACKING/MPACK_WRITE_TRACKING to disable tracking.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer/CI
    participant Docker as Windows Dockerfile (builder)
    participant Ninja as Ninja
    participant CMake as CMake
    participant MSVC as MSVC toolchain
    participant Linker as Linker

    Dev->>Docker: start Windows build
    Docker->>Ninja: install & use Ninja generator
    Ninja->>CMake: configure (reads FLB_EXTRA_CMAKE_CXX_* vars)
    CMake->>MSVC: apply per-config flags (/utf-8, runtime via delayed vars)
    MSVC->>Linker: compile & link objects
    Linker->>Dev: produce final binary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

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

Poem

🐰 I nibbled flags in twilight code,
Holding hops until C++ showed,
Ninja leapt upon Windows ground,
UTF‑8 sang without a sound,
Static threads and builds unbound.

🚥 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 accurately summarizes the main focus of the changeset: CMake project fixes for MS Visual C++ (MSVC) compiler, which is reflected across multiple files including CMakeLists.txt, lib/onigmo/CMakeLists.txt, and the Windows Dockerfile.
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
@mabrarov
Copy link
Contributor Author

mabrarov commented Feb 5, 2026

Hi dear maintainers,

I appreciate if you can find time to review this PR, because it is essential for development of Fluent Bit on / for Windows (e.g. debugging).

Thank you.

Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
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