Skip to content

Fix Windows CI: pin windows-2022 -- new image's clang-cl 22 rejects bundled SDL's _m_prefetch - #119

Open
arekbr wants to merge 1 commit into
slajerek:masterfrom
arekbr:fix/ci-windows-pin-2022
Open

Fix Windows CI: pin windows-2022 -- new image's clang-cl 22 rejects bundled SDL's _m_prefetch#119
arekbr wants to merge 1 commit into
slajerek:masterfrom
arekbr:fix/ci-windows-pin-2022

Conversation

@arekbr

@arekbr arekbr commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The Windows job dies compiling MTEngineSDL (single error in the whole log):

SDL_endian.h(40,1): error : definition of builtin function '_m_prefetch'

Nothing changed in either repo. The windows-2025-vs2026 runner image was updated between the last green run (June, clang-cl 20.1.8) and now (clang-cl 22.1.3). Since clang 21, _m_prefetch is a compiler builtin, and the SDL 2.28.5 header bundled in MTEngineSDL redefines it under a plain #ifdef __clang__ (an old Clang-11-vs-winnt.h workaround). There were no CI runs between June and the #114/#115 merges, so the failure surfaced on the first push after the image update -- the merged PRs touch neither MTEngineSDL nor the workflow. (Both June and August runs used the same VS-2026 image family and the same MSVC 14.51 -- the only variable that moved is the bundled clang: 20.1.8 green, 22.1.3 red.)

This PR: pin windows-2022 (VS 2022, clang-cl 19.x, servicing-only -- its clang stays below 21). One-line change, buys a working CI immediately.

The proper fix is a one-line guard change in MTEngineSDL's bundled header, mirroring what upstream SDL2 did on their branch (not yet in any SDL2 release -- 2.32.10 still has the plain #ifdef):

-#ifdef __clang__
+#if defined(__clang__) && !_SDL_HAS_BUILTIN(_m_prefetch)

(with the underscore -- _SDL_HAS_BUILTIN is the SDL2 spelling; upstream's first attempt used the SDL3 name SDL_HAS_BUILTIN and did not compile, they fixed it in a follow-up commit. Safe for older toolchains: clang 11-20 report no such builtin, so the workaround stays active for them.) Since AGENTS.md says MTEngineSDL changes need your sign-off: say the word and I'll send that PR there too, then this pin can go back to windows-latest.

🤖 Generated with Claude Code

…undled SDL header

The Windows job dies compiling MTEngineSDL:

  SDL_endian.h(40,1): error : definition of builtin function '_m_prefetch'

What changed: nothing in either repo. The windows-2025-vs2026 runner image was
updated between the last green run (June, image 20260608 with clang-cl 20.1.8)
and now (image 20260728 with clang-cl 22.1.3). Since clang 21, _m_prefetch is a
compiler builtin, and the SDL 2.28.5 header bundled in MTEngineSDL redefines it
under a plain '#ifdef __clang__' (an old Clang-11-vs-winnt.h workaround).
There were no CI runs between June and the slajerek#114/slajerek#115 merges, so the failure
surfaced on the first push after the image update -- the merged PRs touch
neither MTEngineSDL nor the workflow.

This pin buys a working CI: windows-2022 ships VS 2022 (clang-cl 19.x) and is
servicing-only, so its clang will stay below 21.

The proper fix lives in MTEngineSDL's bundled header and mirrors what upstream
SDL2 did (their branch, not yet in any release):

  -#ifdef __clang__
  +#if defined(__clang__) && !_SDL_HAS_BUILTIN(_m_prefetch)

(with the underscore: _SDL_HAS_BUILTIN is the SDL2 spelling; upstream's first
attempt used the SDL3 name and did not compile, fixed in their follow-up).
Safe for older toolchains: clang 11-20 report no such builtin, so the
workaround stays for them. Happy to send that PR to MTEngineSDL if wanted --
then this pin can go back to windows-latest.
@arekbr

arekbr commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Additional measurements backing both the pin and the proper patch, done on real toolchains:

clang-cl 19.1.7 (the version windows-2022 ships): both the current #ifdef __clang__ branch and the patched guard compile fine; __has_builtin(_m_prefetch) = 0 there, so the workaround stays active. Confirms the pin is safe and the patch changes nothing for older toolchains.

clang 22.1.8 (Homebrew LLVM, same major as the failing runner): __has_builtin(_m_prefetch) = 1, and preprocessing shows the patched guard cleanly cuts the redefinition out, letting the compiler builtin take over -- exactly the mechanism that removes the CI error. The patched file compiles clean.

One honest caveat: I could not reproduce the hard error itself outside CI -- upstream LLVM 22.1.8's clang-cl accepts my minimal repro of the header block, while the runner's MS-built clang-cl 22.1.3 clearly rejects it in the log. Microsoft ships its own LLVM build, so the error's severity may differ between distributions. That does not change the math: the pinned clang 19 has no builtin (measured), and the patched guard is inert where the builtin is absent and removes the redefinition where it is present (measured).

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