cudaPackages.cuda_nvcc: patch math_functions.h signatures

Fix compatibility with glibc 2.42
This commit is contained in:
Gaetan Lepage
2026-01-26 14:06:13 +00:00
parent 19981b96a8
commit eb6a294bd8

View File

@@ -6,6 +6,7 @@
cudaAtLeast,
cudaOlder,
cuda_cccl,
glibc,
lib,
libnvvm,
makeBinaryWrapper,
@@ -163,6 +164,32 @@ buildRedist (finalAttrs: {
"''${!outputBin:?}/bin/nvcc" \
--prefix PATH : ${lib.makeBinPath [ backendStdenv.cc ]}
''
# Fix compatibility with glibc 2.42:
# The cospi|sinpi|rsqrt function signatures in include/common/math_functions.h do not match
# glibc 2.42's.
# Indeed, there they are declared with noexcept(true) which is not the case in cuda_nvcc.
+ lib.optionals (lib.versionAtLeast glibc.version "2.42") ''
nixLog "Patching math_functions.h signatures to match glibc's ones"
substituteInPlace "''${!outputInclude:?}/include/crt/math_functions.h" \
--replace-fail \
"sinpi(double x);" \
"sinpi(double x) noexcept (true);" \
--replace-fail \
"sinpif(float x);" \
"sinpif(float x) noexcept (true);" \
--replace-fail \
"cospi(double x);" \
"cospi(double x) noexcept (true);" \
--replace-fail \
"cospif(float x);" \
"cospif(float x) noexcept (true);" \
--replace-fail \
"rsqrt(double x);" \
"rsqrt(double x) noexcept (true);" \
--replace-fail \
"rsqrtf(float x);" \
"rsqrtf(float x) noexcept (true);"
''
);
brokenAssertions = [