Skip to content

Compile bug: Seemingly random failures when building HIP/ROCm Windows #22570

Closed as not planned

Description

@jdluzen

Git commit

beb42ff

Operating systems

Windows

GGML backends

HIP

Problem description & steps to reproduce

Trying to compile on Windows 11 with HIP. SDK is 7.1. I see the HIP_PATH properly specified.
The big problem for me is that this seems to be random. Sometimes build succeeds, sometimes it fails.
ggml-hip.dll has also never been built. Should it have been?

-DGGML_CCACHE=OFF had no effect.

First Bad Commit

No response

Compile command

set PATH=%HIP_PATH%\bin;%PATH%
cmake -S . -B build -G Ninja -DGPU_TARGETS=gfx1100 -DGGML_HIP=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
cmake --build build

**Sometimes** it works, sometimes not. When it does work, I get the bin dir full of .exes, but WITHOUT the `ggml-hip.dll` file.

Relevant log output

When it does not work, I get tons of the errors like:

In file included from <built-in>:1:
In file included from C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__clang_hip_runtime_wrapper.h:144:
C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__clang_cuda_math_forward_declares.h:92:17: error: __device__ function 'isgreater' cannot overload __host__ __device__ function 'isgreater'
   92 | __DEVICE__ bool isgreater(double, double);
      |                 ^
C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\MSVC\14.51.36231\include\cmath:688:17: note: previous declaration is here
  688 | _CLANG_BUILTIN2(isgreater)
      |                 ^
In file included from <built-in>:1:
In file included from C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__clang_hip_runtime_wrapper.h:144:
C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__clang_cuda_math_forward_declares.h:93:17: error: __device__ function 'isgreaterequal' cannot overload __host__ __device__ function 'isgreaterequal'
   93 | __DEVICE__ bool isgreaterequal(double, double);
      |                 ^
C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\MSVC\14.51.36231\include\cmath:689:17: note: previous declaration is here
  689 | _CLANG_BUILTIN2(isgreaterequal)
...
20 errors generated when compiling for gfx1100.
ninja: build stopped: subcommand failed.

Activity

  1. jmmartinez commented on May 28, 2026

    @jmmartinez

    Hello,

    There is a problem with clang's header wrappers.

    Some more info:

    • clang/hipcc uses some include wrappers that provide workarounds when using C++ standard library functions on device code. In this case, it provides a __device__ version of isgreater(double, double).
    • after an update on Microsoft's STL microsoft/STL@38d7248#diff-3fa97ceb95d524432661f01d4b34509c6d261a2f7f45ddcf26f79f55b3eec88aR609 , constexpr was added when using clang to compile some math functions (like isgreater(double, double));
    • constexpr implies both __host__ and __device__; so the constexpr declaration collides with the __device__ only declaration.

    I'm working on a fix on the clang/hipcc side.

    As a workaround, you can probably tinker with the __clang_cuda_math_forward_declares.h file (I'd try commenting the __DEVICE__ functions) and see if that works.

  2. jmmartinez commented on Jun 4, 2026

    @jmmartinez

    I've started a fix for this issue in: llvm/llvm-project#201563

  3. Dixon-Cider commented on Jun 23, 2026

    @Dixon-Cider

    Workaround: ROCm 7.1.1 (Windows) clang + MSVC ≥14.40 <cmath> collision

    Self-contained repro + fix for anyone hitting this on a fresh Windows toolchain.

    Symptom — building HIP device code (-x hip --offload-arch=gfx1201) with ROCm 7.1.1's bundled clang-21 against MSVC 14.44/14.51:

    error: __device__ function 'isless' cannot overload __host__ __device__ function 'isless'
    

    Same for isgreater/isgreaterequal/islessequal/islessgreater/isunordered. Looks "random" because it only fires on TUs that pull <cmath> in device-side.

    Cause — MSVC ≥14.40 declares those comparison fns constexpr in <cmath> (under #ifdef __clang__), so under HIP they become implicitly __host__ __device__ and collide with clang's __device__-only forward-declares in __clang_cuda_math_forward_declares.h. Fixed upstream by LLVM #201563 (merged 2026-06-09); ROCm 7.1.1's clang predates it.

    Fix (one line, no toolset downgrade) — in ...\ROCm\7.1\lib\clang\21\include\__clang_hip_runtime_wrapper.h, in the #if !defined(__HIPCC_RTC__) block, put the forward-declares include before <cmath>:

    #include <__clang_cuda_math_forward_declares.h>
    #include <cmath>

    This mirrors #201563 (device forward-declares first → MSVC's constexpr cmath isn't promoted to host+device). The full HIP build then completes on MSVC 14.51, no version pin. It's a reorder, not a delete — commenting the declares out instead makes it worse. Drop the edit once a HIP SDK ships clang with #201563.

    Version-pinning instead is awkward: 14.44/14.51 hit the cmath error, 14.29 fails differently (host <functional> reinterpret_cast), and the clean pin is reportedly 14.39 (VS 17.9), which I didn't have. The header reorder is simpler.

    Env: R9700 (gfx1201), Windows 11, ROCm HIP SDK 7.1.1. The same collision was reported building flash-attention for gfx1201 in ROCm/llvm-project#2669. Longer writeup + a patch script: https://github.com/Dixon-Cider/gemma4-mtp-rocm-windows-r9700

  4. github-actions commented on Aug 7, 2026

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions