Skip to content

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

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

build: CMake project fixes for MS Visual C++ compiler#11397
mabrarov wants to merge 11 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.
  • Speedup of building debug version on Windows by disabling Link-Time Code Generation for Debug build only.

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 builder switched to Ninja; build invocation updated.
    • Added delayed-extension variables for C++ compiler/linker flags and applied when C++ is enabled.
    • Improved MSVC handling: UTF‑8 enabled; static-runtime selection moved to per-configuration logic; MK_DEBUG disabled on MSVC.
    • Coverage and platform-specific linker-flag handling improved; MPack tracking explicitly disabled.
  • Documentation

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

    • Fixed 64-bit file-mapping size handling on Windows.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds delayed-extension CXX/link flag variables, moves MSVC runtime and /utf-8 handling into per-config delayed workflow, updates Windows builder to use Ninja/vcpkg, refines CMake flag handling across platforms, and fixes 64-bit file-mapping on Windows.

Changes

Cohort / File(s) Summary
Top-level CMake orchestrator
CMakeLists.txt
Adds FLB_EXTRA_CMAKE_CXX_FLAGS and FLB_EXTRA_CMAKE_CXX_LINK_FLAGS (empty defaults), implements delayed-extension merging for C++ flags, moves MSVC /MT management to per-config workflow, adds /utf-8 and coverage adjustments, and gates MK_DEBUG off for MSVC.
Onigmo MSVC CMake tweaks
lib/onigmo/CMakeLists.txt
Switches MSVC runtime handling to CMAKE_MSVC_RUNTIME_LIBRARY and per-config CMAKE_C_FLAGS_<CONFIG> transforms, adds /utf-8, removes global /MT injection and forced CMAKE_BUILD_TYPE, and conditions LTCG per-config.
Developer guide & vcpkg flow
DEVELOPER_GUIDE.md
Adds vcpkg manifest guidance, Windows vcpkg integration steps, refactors PowerShell Flex/Bison blocks, and updates final build invocation to --config Release --clean-first.
Windows Docker builder
dockerfiles/Dockerfile.windows
Installs Ninja, switches builder stage to Ninja generator, removes explicit -DCMAKE_BUILD_TYPE=Release and multi-config NMake invocation, and uses Ninja single-config build.
Platform/Coverage/MPack adjustments
CMakeLists.txt (Unicode/wasm/armv7l/FreeBSD/coverage sections)
Marks platform blocks to extend CXX/CXX_LINK flags via delayed-extension when C++ is enabled, adds -fprofile-update=atomic where applicable, and defines MPACK_READ_TRACKING/MPACK_WRITE_TRACKING to disable tracking.
Windows mapping fix
lib/chunkio/src/cio_file_win32.c
Add limits.h include and compute high/low 32-bit parts of mapping size safely; pass correct DWORD high/low to CreateFileMappingA for large mappings.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer/CI
    participant Docker as Windows Builder
    participant Ninja as Ninja
    participant CMake as CMake
    participant MSVC as MSVC Toolchain
    participant Linker as Linker

    Dev->>Docker: trigger Windows build
    Docker->>Ninja: install & use Ninja generator
    Ninja->>CMake: configure (reads FLB_EXTRA_CMAKE_CXX_* and vcpkg toolchain)
    CMake->>MSVC: apply per-config flags (/utf-8, runtime selection, delayed CXX flags)
    MSVC->>Linker: compile & link
    Linker->>Dev: produce artifact
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

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

Poem

🐰 I hid a flag where CMake sleeps,

Delayed till C++ wakes from heaps.
Ninja hopped in with vcpkg cheer,
UTF‑8 hummed, runtimes found their gear,
Mappings count true bytes — hop, hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: CMake project fixes for the MS Visual C++ compiler, which aligns with the primary focus of the changeset.

✏️ 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
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>
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

Labels

docs-required ok-package-test Run PR packaging tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants