[clang] [clang][CUDA] Define _NV_RSQRT_SPECIFIER for glibc-2.42/cuda-13.2 compatibility (PR #185701)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 10 10:32:45 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Artem Belevich (Artem-B)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/185701.diff
1 Files Affected:
- (modified) clang/lib/Headers/__clang_cuda_runtime_wrapper.h (+15)
``````````diff
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")
``````````
</details>
https://github.com/llvm/llvm-project/pull/185701
More information about the cfe-commits
mailing list