https://github.com/Artem-B created 
https://github.com/llvm/llvm-project/pull/185701

CUDA-13.2 defines _NV_RSQRT_SPECIFIER to make its headers compileable with 
glibc 2.42+. However, clang does not include the header that defines the macro, 
and has to define it by itself.

>From e791730d5cf70053b286cd43a658d168da7f5f32 Mon Sep 17 00:00:00 2001
From: Artem Belevich <[email protected]>
Date: Tue, 10 Mar 2026 10:12:58 -0700
Subject: [PATCH] [clang][CUDA] Define _NV_RSQRT_SPECIFIER for
 glibc-2.42/cuda-13.2 compatibility

CUDA-13.2 defines _NV_RSQRT_SPECIFIER to make its headers compileable
with glibc 2.42+. However, clang does not include the header that
defines the macro, and has to define it by itself.
---
 clang/lib/Headers/__clang_cuda_runtime_wrapper.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h 
b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
index fcf1ea89ad6a3..3ed023b9c72d7 100644
--- a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -45,6 +45,21 @@
 #include <string.h>
 #undef __CUDACC__
 
+// math_functions.h from CUDA 13.2+ defines _NV_RSQRT_SPECIFIER.
+// Clang does not include it, so we need to define it ourselves.
+#if defined(__GNUC__)
+# include <features.h> /* For GLIBC macros */
+# if defined(__GLIBC_PREREQ)
+#  if __GLIBC_PREREQ(2, 42)
+#   define _NV_RSQRT_SPECIFIER noexcept(true)
+#  endif
+# endif
+#endif
+
+#ifndef _NV_RSQRT_SPECIFIER
+# define _NV_RSQRT_SPECIFIER
+#endif
+
 // Preserve common macros that will be changed below by us or by CUDA
 // headers.
 #pragma push_macro("__THROW")

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

Reply via email to