build: fix MinGW-w64 cross-compilation for Windows#114
Open
hjiawei wants to merge 1 commit into
Open
Conversation
- 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>
3 tasks
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 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:
ssize_tandmode_ttypedefs inchunkio_compat.hwith!__MINGW32__— MinGW-w64 already provides both, and redefining them fails to compile.fts.hgate incio_utils.cfrom_MSC_VERto!_WIN32:fts.his absent on any Windows toolchain, not just MSVC.<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.shell32by its lowercase name insrc/CMakeLists.txtso GNU ld resolves the import library; CMake still appends.libfor 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 thefts.h/shell32changes resolve identically under MSVC.