[clang] [Clang][CUDA] Guard curand_mtgp32_kernel.h include with has_include (PR #244945)

Nam Khanh via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 22 00:03:08 PST 2026


namnkahn1607 wrote:

> A better fix would be to backtrack CUDA SDK versions, and find the version which no longer needs inclusion of `curand_mtgp32_kernel.h` from the subset of headers used by the `__clang_cuda_runtime_wrapper.h`, and then conditionally include `curand_mtgp32_kernel` only for the CUDA versions that need it.

I tried removed the workaround on CUDA 12.8, then compiled 2 cases of translation units:
- The one that does not use cuRAND compiles fine, so I can conclude that the wrapper's pre-included headers do not need `curand_mtgp32_kernel.h` on 12.8.
- However, the one with `#include <curand_kernel.h>` fails immediately with `redeclaration of 'blockDim'/'threadIdx' with a different type`.

This also means gating the inclusion using `CUDA_VERSION` based on whether the wrapper's pre-included headers need it would regress cuRAND users on CUDA 12.8.

https://github.com/llvm/llvm-project/pull/244945


More information about the cfe-commits mailing list