Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Contributor
|
We need to send patches into upstream if we wanted to patch bundled libraries. |
hjiawei
force-pushed
the
mingw-ucrt64-cross-build
branch
2 times, most recently
from
July 7, 2026 07:20
4d96c59 to
6dc3994
Compare
Author
Agreed. Each bundled-library change has been submitted upstream. They are listed in the PR description. I will rebase or update the vendored libs once they are merged or brought into the Fluent Bit codebase. |
hjiawei
force-pushed
the
mingw-ucrt64-cross-build
branch
2 times, most recently
from
July 8, 2026 14:20
34b9aba to
b21b836
Compare
hjiawei
force-pushed
the
mingw-ucrt64-cross-build
branch
from
August 6, 2026 06:51
b21b836 to
dd7de3e
Compare
Make the cmake tree usable for a Linux-hosted MinGW-w64 UCRT64 cross-build targeting Windows, building the standard Windows plugin profile from cmake/windows-setup.cmake: - Define _POSIX_THREAD_SAFE_FUNCTIONS so the MinGW headers declare the POSIX gmtime_r()/localtime_r() family, and keep the Winsock char-pointer signature mismatches (warnings under MSVC) from becoming hard errors under GCC 14 and later unless the strict option is set. - Derive the autoconf host triple from the cross compiler when CMAKE_CROSSCOMPILING and no GNU_HOST was given, so the external autotools sub-builds (libbacktrace, jemalloc) configure for the target instead of silently producing build-host objects. - Use plain make for external autotools sub-builds under the Ninja generator on all targets; the $(MAKE) escape only exists in the Make-family generators. - Give the executable an import-library suffix distinct from the shared library's on MinGW, mirroring the MSVC branch; Ninja rejects the duplicate libfluent-bit.dll.a output NMake never noticed. - Link libbacktrace on fluent-bit-static, where the stacktrace helpers are compiled, so GNU ld orders the archive correctly. - Guard the MSVC /W2 warning flag with if(MSVC) in the core and plugin cmake files, link the Windows system libraries by their lowercase names (GNU ld resolves them against import libraries, MSVC accepts them unchanged), and append to FLB_DEPS instead of overwriting it so onigmo-static and friends survive on Windows. - Keep the ELF hardening link flags off for all Windows targets, not just MSVC, since GNU ld does not support them for PE. - Define YAML_DECLARE_STATIC for any Windows toolchain when FLB_LIBYAML_DIR is given; that path carries a static libyaml for MSVC (vcpkg static triplets) and MinGW alike. - Link OpenSSL statically only on MSVC; the MinGW cross-build uses the toolchain's dynamic OpenSSL to avoid GNU ld link-order issues. - Keep FLB_HAVE_UNIX_SOCKET off for non-MSVC Windows builds: the Windows unix socket paths are untested, so keep feature parity with MSVC. - Skip the tools/xxd-c host tool when cross-compiling, since it cannot run on the build host. - Overwrite onigmo's generated config.h with the win32/config.h it ships when cross-compiling to Windows; Onigmo's configure-time probes otherwise inspect the build host and misdetect the target. This keeps the vendored onigmo tree unpatched. - Register in_etw only for MSVC. The plugin decodes events with the TDH API, and MinGW-w64 ships only a stub tdh.h without the TDH_INTYPE_* and TdhGetEventInformation declarations it needs. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
MinGW-w64 UCRT headers already provide strcasecmp(), strncasecmp(), timezone, tzname, usleep() and, with _POSIX_THREAD_SAFE_FUNCTIONS set by the build system, the POSIX gmtime_r()/localtime_r() family, plus a real pthread implementation (winpthreads); redefining them or pulling in monkey's Windows pthread shim breaks compilation. Guard the MSVC replacement shims and route MinGW to <pthread.h>, mapping only the BSD random()/srandom() pair the MinGW unistd.h lacks. Use GCC's __thread for the thread-local basename() buffer since MinGW GCC ignores __declspec(thread), add a PTHREAD_STACK_MIN fallback for the coroutine stack sizing, lowercase the wincrypt.h include for cross-builds from case-sensitive filesystems, and use the Windows gate instead of the MSVC one in flb_langinfo.h. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The header declares flb_net_server_unix() with four parameters, but the fallback stub compiled when FLB_HAVE_UNIX_SOCKET is not set still has the old three-parameter signature, so any platform taking that branch fails to compile with a conflicting declaration error. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The glob(3) fallback and _fullpath() usage apply to any Windows toolchain, not just MSVC, so gate them on _WIN32 instead of _MSC_VER, and lowercase the windows.h include so it resolves against the lowercase MinGW SDK headers when cross-compiling from a case-sensitive filesystem. No behavior change for MSVC builds. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Make the bundled WAMR runtime build for a Windows target with a non-MSVC toolchain: - Select the WAMR platform port from the target system (CMAKE_SYSTEM_NAME) instead of the build host, so a Linux-hosted Windows cross-build uses the windows port rather than compiling the linux port against missing POSIX headers. - The MASM assembler (ASM_MASM) is MSVC-only, so enable it only for MSVC; MinGW and other Windows toolchains still build WASM, using the generic C native-call wrapper the ARM64 Windows build already uses. - Link pathcch and ntdll, which WAMR's Windows platform needs for PathCchCombine (win_file.c) and NtQueryTimerResolution (win_clock.c). MSVC pulls these in via #pragma comment(lib, ...), which GCC ignores; declare them on vmlib-static so CMake orders them after the archive on consumers' link lines. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
GCC on a case-sensitive filesystem cannot resolve the capitalised <ConsoleApi.h>; MSVC is unaffected. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The blocks guard Windows-only functionality, not the MSVC compiler, so MinGW builds must take the same path. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The block guards Windows-only functionality, not the MSVC compiler. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The blocks guard Windows-only functionality, not the MSVC compiler. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Capitalised headers do not resolve on a case-sensitive filesystem under GCC; MSVC is unaffected. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
…table The prototype used empty parens; under C23 that means (void) and conflicts with the definition that takes a size_t. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The block guards Windows functionality, not MSVC; the capitalised header also fails to resolve under GCC. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
The block guards Windows functionality, not MSVC; the capitalised header also fails to resolve under GCC. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Only test the socket type when the platform provides the macro. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Widen the MSVC-only CMake gate to WIN32, link shlwapi by its lowercase name, and lowercase the windows.h includes in the win32 helpers. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
…nGW build Add the missing math.h and we_util.h/we_perflib.h includes and adjust the headers so the plugin compiles with GCC. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Capitalised headers do not resolve on a case-sensitive filesystem under GCC; MSVC is unaffected. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Make the vendored libraries build and run with the MinGW-w64 UCRT toolchain. Each change belongs in the library's own upstream and has been submitted there (monkey/monkey#443, fluent/chunkio#114, wasm-micro-runtime/wasm-micro-runtime#4987), so these hunks are carried here only until those land in a release and are re-vendored. cmetrics (fluent/cmetrics#280) and the top-level flb_libco have completed this cycle and are no longer carried. Two other vendored libraries need no source change: nghttp2 (its inline byte-order fallback compiles as-is; the consumers that include it do not pull in winsock2) and snappy (its MSVC intrinsic path builds under MinGW). Onigmo's cross-compile config is handled in the fluent-bit build files, not by patching its tree. - monkey: select the POSIX threading model for MinGW (winpthreads is a real pthread implementation; the hand-rolled shim stays MSVC-only), guard the MSVC-only typedefs and shims MinGW already provides, widen MSVC-only gates covering Windows functionality to _WIN32, use the standard GCC container_of, and lowercase Windows header includes. The bundled libevent needs no changes. In monkey's bundled deps/flb_libco, check _WIN32 before the architecture so x86_64 MinGW selects the fiber backend, matching lib/flb_libco. The HTTP server build compiles this copy. - chunkio: guard the ssize_t/mode_t typedefs MinGW provides, widen the fts.h gate to _WIN32, lowercase Windows header includes, and link shell32 by its lowercase name. - wasm-micro-runtime: lowercase the pathcch.h include and reword the // comments in win_file.c that end in a backslash; GCC treats a backslash-newline as a line continuation even inside a // comment and swallows the following line of code, while MSVC does not. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Add a compile sanity check that cross-builds fluent-bit.exe for Windows from Linux with the Fedora MinGW-w64 UCRT64 toolchain, so the MinGW support does not bit-rot. The job runs in a fedora container, pins the same cmake version as the other compile checks, cross-builds a static libyaml, and configures with the distribution's ucrt64 toolchain file and the standard Windows plugin defaults. It is a single configuration with no matrix to keep the added CI cost low. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Document the Linux-hosted MinGW-w64 UCRT64 cross-compilation option in the Windows section of the developer guide, pointing at the pr-compile-mingw-cross workflow job as the reference recipe. Signed-off-by: Jiawei Huang <jiawei@tigera.io>
hjiawei
force-pushed
the
mingw-ucrt64-cross-build
branch
from
October 8, 2026 18:35
dd7de3e to
7f717e4
Compare
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This draft PR lets Fluent Bit cross-compile for Windows from a Linux host with the MinGW-w64 UCRT64 toolchain (GCC). The result is a working
fluent-bit.exe(PE32+ x86-64) with the standard Windows plugin set, including the WASM filter.The existing MSVC build compiles the same code as before. MinGW-only fixes are gated on
__MINGW32__orif(MINGW). Gates widened from_MSC_VERto_WIN32take the same branch under MSVC, which defines both.Depends on bundled-library PRs: please do not merge first
Each bundled-library change here has been submitted upstream. The
lib/hunks are carried only so the cross-build works meanwhile. They should arrive through a re-vendor before this PR merges.lib/monkeylib/chunkiolib/wasm-micro-runtime-WAMR-2.4.1WAMR-2.4.5)lib/flb_libco96d61ad, already vendored here, no carrylib/cmetricsFluent Bit links monkey's bundled libco, not
lib/flb_libco.CMakeLists.txtaddslib/flb_libcoonly when nocotarget exists, and monkey definescofirst. So the96d61advendor alone leaves x86_64 MinGW onamd64.c. The monkey carry applies the same backend order to monkey's copy, using the upstream text.These bundled libraries need no source change:
win32/config.hover the misdetected one.Fluent Bit changes
CMakeLists.txt,src/,plugins/)in_etwonly on MSVC (MinGW ships a stubtdh.h)compatheaderssrc/andconfig_format_MSC_VERgates to_WIN32; lowercase Windows header includesfilter_throttle_sizenetworkflb_net_server_unixfallback stub signaturepr-compile-mingw-crossjob inpr-compile-check.yamlonfedora:44DEVELOPER_GUIDE.mdThe network stub and
filter_throttle_sizefixes also apply to non-MinGW builds.Enter
[N/A]in the box, if an item is not applicable to your change.Testing
This is a build and toolchain change, so the runtime items below are N/A. The new CI job cross-builds
fluent-bit.exeon every PR. Local runs onmaster(adee1f53b):fedora:44, CMake 3.31.6)flb-rt-in_http,flb-rt-filter_throttle,flb-it-network,flb-it-config_format*commit_prefix_check.pyover all 20 commits[N/A] Example configuration file for the change
[N/A] Debug log output from testing the change
[N/A] Attached Valgrind output that shows no leaks or memory corruption was found
Run local packaging test showing all targets (including any new ones) build.
Set
ok-package-testlabel 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.