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

>From e9856d7cd3a9953190042a31caebc7f047aeed8d Mon Sep 17 00:00:00 2001
From: namnkahn1607 <[email protected]>
Date: Sun, 22 Nov 2026 04:34:23 +0700
Subject: [PATCH] [Clang][CUDA] Guard curand_mtgp32_kernel.h include with
 has_include

---
 clang/lib/Headers/__clang_cuda_runtime_wrapper.h         | 9 ++++++---
 clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h | 2 --
 2 files changed, 6 insertions(+), 5 deletions(-)
 delete mode 100644 clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h

diff --git a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h 
b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
index 29178bf0db8a1b..456ead71c864d8 100644
--- a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -495,9 +495,11 @@ __device__ inline __cuda_builtin_gridDim_t::operator 
uint3() const {
 // curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
 // mode, giving them their "proper" types of dim3 and uint3.  This is
 // incompatible with the types we give in __clang_cuda_builtin_vars.h.  As as
-// hack, force-include the header (nvcc doesn't include it by default) but
-// redefine dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 
are
-// only used here for the redeclarations of blockDim and threadIdx.)
+// hack, force-include the header when available (nvcc doesn't include it by
+// default) but redefine dim3 and uint3 to our builtin types.  (Thankfully dim3
+// and uint3 are only used here for the redeclarations of blockDim and
+// threadIdx.)
+#if __has_include("curand_mtgp32_kernel.h")
 #pragma push_macro("dim3")
 #pragma push_macro("uint3")
 #define dim3 __cuda_builtin_blockDim_t
@@ -505,6 +507,7 @@ __device__ inline __cuda_builtin_gridDim_t::operator 
uint3() const {
 #include "curand_mtgp32_kernel.h"
 #pragma pop_macro("dim3")
 #pragma pop_macro("uint3")
+#endif
 #pragma pop_macro("__USE_FAST_MATH__")
 #pragma pop_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__")
 
diff --git a/clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h 
b/clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
deleted file mode 100644
index bffa775cb28220..00000000000000
--- a/clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
+++ /dev/null
@@ -1,2 +0,0 @@
-// required for __clang_cuda_runtime_wrapper.h tests
-#pragma once

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to