Skip to content

windows: fix MinGW-w64 build of win_file.c#4987

Open
hjiawei wants to merge 1 commit into
bytecodealliance:mainfrom
hjiawei:mingw-cross-build
Open

windows: fix MinGW-w64 build of win_file.c#4987
hjiawei wants to merge 1 commit into
bytecodealliance:mainfrom
hjiawei:mingw-cross-build

Conversation

@hjiawei

@hjiawei hjiawei commented Jul 6, 2026

Copy link
Copy Markdown

core/shared/platform/windows/win_file.c does not compile with the MinGW-w64 (GCC) toolchain, which WAMR documents as a supported Windows toolchain. Two issues:

  1. Header case. #include "PathCch.h" fails on a case-sensitive filesystem (e.g. cross-compiling from Linux); the MinGW SDK installs the header lowercase as pathcch.h. Lowercasing the include is a no-op on the case-insensitive Windows filesystem MSVC uses.

  2. Comment line-continuation. Three // comments in os_readlinkat() end with a backslash (\??\). GCC treats a backslash at the end of a // comment line as a line continuation, so the following line of code is spliced into the comment and the function fails to parse (-Wcomment: multi-line comment, then a cascade of syntax errors). MSVC does not do this. Appending a trailing word to each comment so it no longer ends in a backslash removes the hazard while keeping the documented NT paths intact (and matches the existing style of the nearby // ... \??\<drive>:\ as a symlink. comment).

Neither change alters behavior; both are inert for the MSVC build.

The enclosing if/else if block is also reformatted — brace placement, indentation, and reflowing the one comment that exceeded the column limit — so the modified lines pass the clang-format check. That part of the diff is whitespace/comment-only.

Testing

Verified by cross-compiling a project that bundles WAMR (Fluent Bit) for Windows from Linux with the Fedora MinGW-w64 UCRT toolchain: vmlib/win_file.c compile and link into a working fluent-bit.exe (PE32+ x86-64). git clang-format (clang-format-14) reports the changed lines clean.

Two issues prevent core/shared/platform/windows/win_file.c from
compiling with the MinGW-w64 (GCC) toolchain:

- The include of "PathCch.h" fails on a case-sensitive filesystem; the
  MinGW SDK installs the header lowercase (pathcch.h).
- Three // comments in os_readlinkat() end with a backslash ("\??\").
  GCC treats a backslash at the end of a // comment line as a line
  continuation, so the following line of code is swallowed into the
  comment and the function fails to parse. MSVC does not. Append a word
  to each so the comment no longer ends in a backslash, keeping the
  documented NT paths intact.

The enclosing if/else-if block is reformatted (brace placement and
indentation) to keep the modified lines clang-format clean.

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