llvm-project
b266cd4c - [Clang][CUDA] Guard curand_mtgp32_kernel.h include with has_include (#244945)

Commit
12 hours ago
[Clang][CUDA] Guard curand_mtgp32_kernel.h include with has_include (#244945) `__clang_cuda_runtime_wrapper.h` forcefully includes `curand_mtgp32_kernel.h`. On a minimal CUDA setup (`cuda -nvcc` and `cuda-cudart-dev` installed), compiling any CUDA code using `clang++` fails with `fatal error: 'curand_mtgp32_kernel.h' file not found`, even when the code does not use cuRAND. The fix guards `#include "curand_mtgp32_kernel.h"` and its surrounding `dim3`/`uint3`, `push_macro`/`define`/`pop_macro` "hack" in `clang/lib/Headers/__clang_cuda_runtime_wrapper.h` with `#if __has_include("curand_mtgp32_kernel.h")`. Removed the stub `clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h`, as keeping the stub in the shared `Inputs/include/` mock tree made the missing-header case really hard to test, as they would vacuously pass even on an unpatched wrapper. It also makes existing tests like `gpu_disabled_math.cpp` and `cuda_with_openmp.cu` exercise the missing-header case. Verified `blockDim` and `threadIdx` redeclarations: **checked headers up to CUDA 13.5** Fixes #244941
Author
Parents
Loading