You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compile bug: Seemingly random failures when building HIP/ROCm Windows #22570
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.
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).
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.
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>:
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.
Activity
jmmartinez commentedon May 28, 2026
Hello,
There is a problem with clang's header wrappers.
Some more info:
clang/hipccuses some include wrappers that provide workarounds when using C++ standard library functions on device code. In this case, it provides a__device__version ofisgreater(double, double).constexprwas added when using clang to compile some math functions (likeisgreater(double, double));constexprimplies both__host__and__device__; so theconstexprdeclaration collides with the__device__only declaration.I'm working on a fix on the
clang/hipccside.As a workaround, you can probably tinker with the
__clang_cuda_math_forward_declares.hfile (I'd try commenting the__DEVICE__functions) and see if that works.[Clang][HIP] Include `__clang_cuda_math_forward_declares.h` before `<…
jmmartinez commentedon Jun 4, 2026
I've started a fix for this issue in: llvm/llvm-project#201563
[Clang][HIP] Include `__clang_cuda_math_forward_declares.h` before `<…
[Clang][HIP] Include `__clang_cuda_math_forward_declares.h` before `<…
Automerge: [Clang][HIP] Include `__clang_cuda_math_forward_declares.h…
Automerge: [Clang][HIP] Include `__clang_cuda_math_forward_declares.h…
[Clang][HIP] Include `__clang_cuda_math_forward_declares.h` before `<…
ROCm Windows: pin vswhere to VS 2022 (MSVC 14.44) to fix HIP clang is…
Dixon-Cider commentedon Jun 23, 2026
Workaround: ROCm 7.1.1 (Windows) clang + MSVC ≥14.40
<cmath>collisionSelf-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: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
constexprin<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>:This mirrors #201563 (device forward-declares first → MSVC's
constexprcmath 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
github-actions commentedon Aug 7, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.