From eb6a294bd8a0a292967214d1254debcc6e41220e Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 26 Jan 2026 14:06:13 +0000 Subject: [PATCH] cudaPackages.cuda_nvcc: patch math_functions.h signatures Fix compatibility with glibc 2.42 --- .../cuda-modules/packages/cuda_nvcc.nix | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkgs/development/cuda-modules/packages/cuda_nvcc.nix b/pkgs/development/cuda-modules/packages/cuda_nvcc.nix index dd2b85934b29d..843736314013b 100644 --- a/pkgs/development/cuda-modules/packages/cuda_nvcc.nix +++ b/pkgs/development/cuda-modules/packages/cuda_nvcc.nix @@ -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 = [