Skip to content

Commit

Permalink
cudaPackages.cuda_cudart: patch cuda-XX.Y.pc
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneSerge committed Dec 22, 2023
1 parent d729e37 commit 3fbafef
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkgs/development/cuda-modules/cuda/overrides.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{cudaVersion, lib}:
{cudaVersion, lib, addDriverRunpath}:
let
inherit (lib) attrsets lists strings;
# cudaVersionOlder : Version -> Boolean
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 3fbafef

Please sign in to comment.