Pull requests / #373

#373 HIP: build with Visual Studio 2026's C++ library (MSVC 14.51+)

closed · @BlueKingMuch · 0 コメント · GitHub で見る

AMD / HIPNVIDIA / CUDAWindowsLinux

本文

With the HIP SDK 7.2 and the C++ library of Visual Studio 2026 18.6 or newer (MSVC 14.51+), every HIP compile on Windows fails, CMake's identification of the HIP compiler included, so the Windows HIP engine (#356) does not get past the configure:

```
__device__ function 'isgreater' cannot overload __host__ __device__ function 'isgreater'
```

Since MSVC 14.51 the Microsoft STL declares `isgreater`, `isless` & co. `constexpr` when the compiler is clang (microsoft/STL#5717). The HIP SDK 7.2's clang includes `<cmath>` before its own `__device__` math declarations, so those `constexpr` functions are already implicitly `__host__ __device__` when clang's `__device__` overloads arrive, and the two collide. clang with llvm/llvm-project#201563 includes its declarations first; llama.cpp ran into the same error (ggml-org/llama.cpp#22570).

## What changes

- `include/strata/hip_compat/windows/cmath` is found for `<cmath>` ahead of the Visual Studio headers. It includes clang's `__clang_cuda_math_forward_declares.h` (HIP compiles only, not hipRTC), then the real `<cmath>` with `#include_next`: the order llvm/llvm-project#201563 gives clang itself.
- `cmake/hip_backend.cmake` puts that folder on `CMAKE_HIP_FLAGS` before `enable_language(HIP)`, on Windows only, so CMake's compiler checks get it too.

With an older MSVC the order makes no difference (its comparisons are not `constexpr`), and a clang that has the fix includes the declarations first by itself; their header has an include guard, so it is read once either way. Linux and CUDA builds never see the folder.

## Tested

Windows 11, Visual Studio 2026 Build Tools (MSVC 14.51), HIP SDK 7.2 (clang 21), CMake 4.0.1, RX 6800. Without the folder the configure stops at the HIP compiler's identification with the error above (that compile is CMake's own test file, so it does not depend on Strata's sources; seen here on 0.1.30 with #247's Windows build). With it, 0.1.31 with #356 and #311 configures, builds and runs.

Not tested with MSVC 14.50 or older. Going by the STL's changelog and sources, those declare these comparisons `inline`, not `constexpr`, so they should not need this, and the reordering does nothing there.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015Ld5YDzuKW1hgMVwwgRZDP

関連リンク

インストール・モデル・リリースへの站内リンク。