Skip to content

Conversation

B1rds3y
Copy link

@B1rds3y B1rds3y commented Sep 15, 2025

Title: Guard ThreadPowerThrottling block for non-MSVC compilers

Description:
This patch wraps the ThreadPowerThrottling block in ggml-cpu.c with an
MSVC-only preprocessor guard so MinGW/GCC builds don't attempt to compile
Windows SDK-only types (e.g. THREAD_POWER_THROTTLING_STATE).

Patch snippet (apply inside llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c where the
ThreadPowerThrottling block appears):

/* Guard MSVC-only ThreadPowerThrottling block so MinGW/GCC do not compile
   Windows SDK-only types. */
#if defined(_MSC_VER)
#if _WIN32_WINNT >= 0x0602
    /* existing ThreadPowerThrottling code that references
       THREAD_POWER_THROTTLING_STATE and related symbols */
#endif
#endif // defined(_MSC_VER)

Notes:

  • This change keeps the existing _WIN32_WINNT guard and only adds a
    surrounding #if defined(_MSC_VER) so non-MSVC compilers skip the block.
  • It is intentionally minimal and should be safe for MSVC builds.

Suggested PR title:
Guard ThreadPowerThrottling block in ggml-cpu.c for non-MSVC compilers

Suggested PR description:
The ThreadPowerThrottling block references Windows SDK-only types which
cause MinGW/GCC builds to fail with unknown type errors. This change adds
an MSVC-only guard so that MinGW/GCC skip the block. MSVC builds are
unaffected.

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Sep 15, 2025
@jeffbolznv
Copy link
Collaborator

Can you try changing the value of GGML_WIN_VER in ggml/cmakelists.txt to a high enough value to enable this command instead?

@slaren
Copy link
Member

slaren commented Sep 15, 2025

I believe this is only an issue in old versions of mingw. There is no reason to disable it for all mingw versions. We have CI that tests the build in mingw (msys2).

@jeffbolznv
Copy link
Collaborator

IIUC we're supposed to set the minimum version we support via _WIN32_WINNT (https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170) and we're setting it to something less than win8 which i think is unintended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants