If you are facing errors like the following when trying to complie applications with NVCC / CUDA 13.1 on Fedora 43
/usr/include/bits/mathcalls.h(206): error: exception specification is
incompatible with that of previous function "rsqrt" (declared at line 629
of
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern double rsqrt (double __x) noexcept (true); extern double __rsqrt (double __x) noexcept (true);
^
/usr/include/bits/mathcalls.h(206): error: exception specification is
incompatible with that of previous function "rsqrtf" (declared at line 653
of
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern float rsqrtf (float __x) noexcept (true); extern float __rsqrtf (float __x) noexcept (true);
^
Its likely due to the fact that glibc’s <math.h> declares rsqrt with noexcept(true), but CUDA’s headers declare it without noexcept (or with a different exception specification).
GCC 14 + glibc are now providing rsqrt/rsqrtf in the standard math library, and there’s a conflict with CUDA’s declarations.
The simplest path is to modify the CUDA headers for math_functions.h to match the glibc math.h headers. The following worked for me
sudo patch -b /usr/local/cuda/targets/x86_64-linux/include/crt/math_functions.h << 'EOF'
--- a/math_functions.h
+++ b/math_functions.h
@@ -626,7 +626,7 @@
*
* \note_accuracy_double
*/
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double rsqrt(double x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double rsqrt(double x) noexcept (true);
/**
* \ingroup CUDA_MATH_SINGLE
@@ -650,7 +650,7 @@
*
* \note_accuracy_single
*/
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float rsqrtf(float x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float rsqrtf(float x) noexcept (true);
#if defined(__QNX__) && !defined(_LIBCPP_VERSION)
namespace std {
EOF
Hope its helpful for others