cudaPackages.setupCudaHook: rewrite cudartFlags, remove infinite recursion in cudatoolkit

We don't need to add the extra nvcc flags to locate cudart when using
cudatoolkit because it comes in the merged layout and nvcc doesn't have
any trouble locating dependencies in the same prefix
This commit is contained in:
Someone Serge 2023-12-04 18:56:55 +00:00
parent a7891f2ada
commit 182e6b41d0
No known key found for this signature in database
GPG Key ID: 7B0E3B1390D61DA4
2 changed files with 10 additions and 5 deletions

View File

@ -69,9 +69,13 @@ final: prev: let
# - the cuda_runtime.h header, which is in the dev output
# - the dynamic library, which is in the lib output
# - the static library, which is in the static output
substitutions.cudartInclude = "${final.cuda_cudart.dev}";
substitutions.cudartLib = "${final.cuda_cudart.lib}";
substitutions.cudartStatic = "${final.cuda_cudart.static}";
substitutions.cudartFlags = let cudart = final.cuda_cudart; in
builtins.concatStringsSep " " (final.lib.optionals (final ? cuda_cudart) ([
"-I${final.lib.getDev cudart}/include"
"-L${final.lib.getLib cudart}/lib"
] ++ final.lib.optionals (builtins.elem "static" cudart.outputs) [
"-L${cudart.static}/lib"
]));
}
./hooks/setup-cuda-hook.sh)
{ });

View File

@ -55,8 +55,9 @@ setupCUDAToolkitCompilers() {
# CMake's enable_language(CUDA) runs a compiler test and it doesn't account for
# CUDAToolkit_ROOT. We have to help it locate libcudart
if [[ -z "${nvccDontPrependCudartFlags-}" ]] ; then
export NVCC_APPEND_FLAGS+=" -L@cudartLib@/lib -L@cudartStatic@/lib -I@cudartInclude@/include"
local cudartFlags="@cudartFlags@"
if [[ -z "${nvccDontPrependCudartFlags-}" ]] && [[ -n "${cudartFlags:-}" ]] ; then
export NVCC_APPEND_FLAGS+=" $cudartFlags"
fi
}