Skip to content

build: fix MinGW-w64 cross-compilation for Windows#114

Open
hjiawei wants to merge 1 commit into
fluent:masterfrom
hjiawei:mingw-cross-build
Open

build: fix MinGW-w64 cross-compilation for Windows#114
hjiawei wants to merge 1 commit into
fluent:masterfrom
hjiawei:mingw-cross-build

Conversation

@hjiawei

@hjiawei hjiawei commented Jul 6, 2026

Copy link
Copy Markdown

This lets chunkio build for a Windows target with the MinGW-w64 UCRT toolchain (GCC), in addition to MSVC. The changes are no-ops for MSVC builds:

  • Guard the ssize_t and mode_t typedefs in chunkio_compat.h with !__MINGW32__ — MinGW-w64 already provides both, and redefining them fails to compile.
  • Widen the fts.h gate in cio_utils.c from _MSC_VER to !_WIN32: fts.h is absent on any Windows toolchain, not just MSVC.
  • Lowercase the capitalized Windows header includes (<Shlobj.h><shlobj.h>, <Windows.h><windows.h>) so they resolve when cross-compiling from a case-sensitive filesystem. MSVC on a case-insensitive filesystem is unaffected.
  • Link shell32 by its lowercase name in src/CMakeLists.txt so GNU ld resolves the import library; CMake still appends .lib for MSVC.

Testing

Verified by cross-compiling Fluent Bit (which bundles chunkio) for Windows from Linux with the Fedora MinGW-w64 UCRT toolchain — chunkio compiles and links into a working fluent-bit.exe (PE32+ x86-64). The MSVC build path is unchanged: the typedef guards keep MSVC on its existing branch, the header-case changes are inert on a case-insensitive filesystem, and the fts.h/shell32 changes resolve identically under MSVC.

- Guard the ssize_t and mode_t typedefs that MinGW-w64 already provides.
- Widen the fts.h gate that covers Windows functionality to _WIN32.
- Lowercase capitalized Windows header includes so they resolve on a
  case-sensitive filesystem when cross-compiling from Linux.
- Link shell32 by its lowercase name so GNU ld resolves the import
  library.

Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant