Files
fearkov e55a76c38e Let the runtime cross-compile with MinGW
Two macro collisions, each of which stops the build outright on
x86_64-w64-mingw32. Together they are 51 errors before anything links.

__debugbreak in xbox_winnt.h was guarded on !defined(_MSC_VER), which is true
for MinGW GCC, and the block sits above the #include <windows.h> below it. So
the function-like macro is defined first, and _mingw.h then tries to declare
the real intrinsic:

    void __cdecl __debugbreak(void);

The preprocessor reads that (void) as an argument -- "macro '__debugbreak'
passed 1 arguments, but takes just 0" -- 48 times. The guard has to exclude
every _WIN32 host, not only _MSC_VER: where a Windows SDK exists, its own
__debugbreak is the better one anyway, since it traps to a debugger where
__builtin_trap() raises SIGILL. Same guard in templates/runtime/recomp_types.h,
where !defined(__debugbreak) does not help either -- MinGW declares it as a
function, not a macro, so that test passes and the macro is defined regardless.

KernelMode and UserMode were object-like macros. Both are ordinary words, and
the Windows SDK uses them as struct member names: WINBOOL KernelMode in
<rpcasync.h>, and the KernelMode/UserMode bitfields of
SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION in <winnt.h>. A macro
rewrites those declarations to "WINBOOL 0;" in any translation unit that
reaches an SDK header after kernel.h. They are enum constants now, which live
in the ordinary identifier namespace; struct members have their own, so the
names coexist and the fix does not depend on include order. The values are
unchanged.

cmake/mingw-w64-x86_64.cmake is the toolchain file, so the claim in this
message is one command rather than a paragraph a reader has to reconstruct:

    cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w64-x86_64.cmake

It is inert unless CMAKE_TOOLCHAIN_FILE names it, so a Visual Studio build is
unaffected by the file existing. MINGW_TRIPLET overrides the prefix, because
distributions disagree about it.

Nothing here changes what MSVC sees: both guards only widen a condition, and
the enum constants are the same 0 and 1.

CONTRIBUTING lists Windows and MSVC as the environment, so this is not a
broken build being repaired -- it adds a host. With it, all eight runtime
libraries and the three d3d8 smoke targets build clean under MinGW, by the
command above.
2026-09-19 15:08:55 -04:00
..