From cfa07014b6af63298365329c8ffc2a132941d985 Mon Sep 17 00:00:00 2001 From: Someone Serge Date: Fri, 22 Dec 2023 00:33:55 +0000 Subject: [PATCH] cudaPackages.cuda_cudart: patch cuda-XX.Y.pc --- pkgs/development/cuda-modules/cuda/overrides.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/development/cuda-modules/cuda/overrides.nix b/pkgs/development/cuda-modules/cuda/overrides.nix index bcb41f43e98eb..b835b5350aee0 100644 --- a/pkgs/development/cuda-modules/cuda/overrides.nix +++ b/pkgs/development/cuda-modules/cuda/overrides.nix @@ -1,4 +1,4 @@ -{cudaVersion, lib}: +{cudaVersion, lib, addDriverRunpath}: let inherit (lib) attrsets lists strings; # cudaVersionOlder : Version -> Boolean @@ -42,6 +42,20 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) { lists.optionals (cudaVersionAtLeast "12.0") [final.libnvjitlink.lib] ); + cuda_cudart = prev.cuda_cudart.overrideAttrs ( + prevAttrs: { + + # The libcuda stub's pkg-config doesn't follow the general pattern: + postPatch = prevAttrs.postPatch or "" + '' + while IFS= read -r -d $'\0' path ; do + sed -i \ + -e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib/stubs|" \ + -e "s|^Libs\s*:\(.*\)\$|Libs: \1 -Wl,-rpath,${addDriverRunpath.driverLink}/lib|" \ + "$path" + done < <(find -iname 'cuda-*.pc' -print0) + ''; + }); + cuda_compat = prev.cuda_compat.overrideAttrs ( prevAttrs: { env.autoPatchelfIgnoreMissingDeps =