Skip to content

Instantly share code, notes, and snippets.

@joanbm
Created August 3, 2025 19:59
Show Gist options
  • Save joanbm/7960974c08bd7f7367a09e09e6b8935c to your computer and use it in GitHub Desktop.
Save joanbm/7960974c08bd7f7367a09e09e6b8935c to your computer and use it in GitHub Desktop.
Fix for CUDA 10.2 for glibc 2.42
From 598bc565905de1de2146e781013882bc9577ff21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= <[email protected]>
Date: Sun, 3 Aug 2025 19:43:40 +0000
Subject: [PATCH] Updates headers for glibc-2.42
Match the extern definitions in cuda-crt headers with the changes in glibc-2.42.
/usr/include/bits/mathcalls.h(206): error: exception specification is
incompatible with that of previous function "rsqrt"
/opt/cuda-10.2/include/crt/math_functions.h(684): here
/usr/include/bits/mathcalls.h(206): error: exception specification is
incompatible with that of previous function "rsqrtf"
/opt/cuda-10.2/include/crt/math_functions.h(754): here
See-Also: https://sourceware.org/git/?p=glibc.git;a=commit;h=77261698b4e938020a1b2032709a54d942ba330f
---
.../targets/x86_64-linux/include/crt/math_functions.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/builds/cuda-toolkit/targets/x86_64-linux/include/crt/math_functions.h b/builds/cuda-toolkit/targets/x86_64-linux/include/crt/math_functions.h
index 9d1d7cc..45f4c45 100644
--- a/builds/cuda-toolkit/targets/x86_64-linux/include/crt/math_functions.h
+++ b/builds/cuda-toolkit/targets/x86_64-linux/include/crt/math_functions.h
@@ -681,7 +681,11 @@ extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double __cdecl sqrt(
*
* \note_accuracy_double
*/
+#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 42
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double rsqrt(double x) noexcept (true);
+#else
extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double rsqrt(double x);
+#endif
/**
* \ingroup CUDA_MATH_SINGLE
@@ -751,7 +755,12 @@ extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double rsqrt
*
* \note_accuracy_single
*/
+
+#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 42
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float rsqrtf(float x) noexcept (true);
+#else
extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float rsqrtf(float x);
+#endif
#if defined(__QNX__) && !defined(_LIBCPP_VERSION)
namespace std {
--
2.50.1
@joanbm
Copy link
Author

joanbm commented Aug 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment