From 02966afc5481730c3ff8e09cb2c7a79d96b63be0 Mon Sep 17 00:00:00 2001 From: Connor Baker Date: Wed, 3 Apr 2024 18:50:44 +0000 Subject: [PATCH] cudaPackages.setupCudaHook: always set return explicitly On NixOS, the the return status is that of the last command executed within the function or script. When we're doing tests immediately before the return, the value you end up returning might not be what you want. --- .../cuda-modules/setup-hooks/setup-cuda-hook.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/development/cuda-modules/setup-hooks/setup-cuda-hook.sh b/pkgs/development/cuda-modules/setup-hooks/setup-cuda-hook.sh index 95f5fd884e42..dad78cfebded 100644 --- a/pkgs/development/cuda-modules/setup-hooks/setup-cuda-hook.sh +++ b/pkgs/development/cuda-modules/setup-hooks/setup-cuda-hook.sh @@ -24,8 +24,8 @@ extendcudaHostPathsSeen() { (( "${NIX_DEBUG:-0}" >= 1 )) && echo "extendcudaHostPathsSeen $1" >&2 local markerPath="$1/nix-support/include-in-cudatoolkit-root" - [[ ! -f "${markerPath}" ]] && return - [[ -v cudaHostPathsSeen[$1] ]] && return + [[ ! -f "${markerPath}" ]] && return 0 + [[ -v cudaHostPathsSeen[$1] ]] && return 0 cudaHostPathsSeen["$1"]=1 @@ -33,7 +33,7 @@ extendcudaHostPathsSeen() { local cudaOutputName read -r cudaOutputName < "$markerPath" - [[ -z "$cudaOutputName" ]] && return + [[ -z "$cudaOutputName" ]] && return 0 local oldPath="${cudaOutputToPath[$cudaOutputName]-}" [[ -n "$oldPath" ]] && echo "extendcudaHostPathsSeen: warning: overwriting $cudaOutputName from $oldPath to $1" >&2 @@ -59,7 +59,7 @@ setupCUDAToolkitCompilers() { echo Executing setupCUDAToolkitCompilers >&2 if [[ -n "${dontSetupCUDAToolkitCompilers-}" ]] ; then - return + return 0 fi # Point NVCC at a compatible compiler @@ -99,7 +99,7 @@ preConfigureHooks+=(setupCUDAToolkitCompilers) propagateCudaLibraries() { (( "${NIX_DEBUG:-0}" >= 1 )) && echo "propagateCudaLibraries: cudaPropagateToOutput=$cudaPropagateToOutput cudaHostPathsSeen=${!cudaHostPathsSeen[*]}" >&2 - [[ -z "${cudaPropagateToOutput-}" ]] && return + [[ -z "${cudaPropagateToOutput-}" ]] && return 0 mkdir -p "${!cudaPropagateToOutput}/nix-support" # One'd expect this should be propagated-bulid-build-deps, but that doesn't seem to work