From 4153e8f02f3f8490f209f9276e667ccbd8797397 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 12 Jun 2024 08:41:39 +0200 Subject: [PATCH] cuda-modules: refactor appending cmakeFlags in setup hook cudaPackages already builts with structuredAttrs, but the cmakeFlags+= pattern incorrectly appends the additional flags to the first array argument with a space - which is now part of that argument itself since #318614, which added support for structuredAttrs to cmake. --- .../cuda-modules/setup-hooks/setup-cuda-hook.sh | 11 ++++++----- 1 file changed, 6 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 6e57c7b1072e..7799d72873a0 100644 --- a/pkgs/development/cuda-modules/setup-hooks/setup-cuda-hook.sh +++ b/pkgs/development/cuda-modules/setup-hooks/setup-cuda-hook.sh @@ -54,7 +54,8 @@ setupCUDAToolkit_ROOT() { fi done - export cmakeFlags+=" -DCUDAToolkit_INCLUDE_DIR=$CUDAToolkit_INCLUDE_DIR -DCUDAToolkit_ROOT=$CUDAToolkit_ROOT" + appendToVar cmakeFlags "-DCUDAToolkit_INCLUDE_DIR=$CUDAToolkit_INCLUDE_DIR" + appendToVar cmakeFlags "-DCUDAToolkit_ROOT=$CUDAToolkit_ROOT" } preConfigureHooks+=(setupCUDAToolkit_ROOT) @@ -72,8 +73,8 @@ setupCUDAToolkitCompilers() { # https://cmake.org/cmake/help/latest/envvar/CUDAHOSTCXX.html # https://cmake.org/cmake/help/latest/variable/CMAKE_CUDA_HOST_COMPILER.html - export cmakeFlags+=" -DCUDA_HOST_COMPILER=@ccFullPath@" - export cmakeFlags+=" -DCMAKE_CUDA_HOST_COMPILER=@ccFullPath@" + appendToVar cmakeFlags "-DCUDA_HOST_COMPILER=@ccFullPath@" + appendToVar cmakeFlags "-DCMAKE_CUDA_HOST_COMPILER=@ccFullPath@" # For non-CMake projects: # We prepend --compiler-bindir to nvcc flags. @@ -85,7 +86,7 @@ setupCUDAToolkitCompilers() { export CUDAHOSTCXX="@ccFullPath@"; fi - export NVCC_PREPEND_FLAGS+=" --compiler-bindir=@ccRoot@/bin" + appendToVar NVCC_PREPEND_FLAGS "--compiler-bindir=@ccRoot@/bin" # NOTE: We set -Xfatbin=-compress-all, which reduces the size of the compiled # binaries. If binaries grow over 2GB, they will fail to link. This is a problem for us, as @@ -94,7 +95,7 @@ setupCUDAToolkitCompilers() { # # @SomeoneSerge: original comment was made by @ConnorBaker in .../cudatoolkit/common.nix if [[ -z "${dontCompressFatbin-}" ]]; then - export NVCC_PREPEND_FLAGS+=" -Xfatbin=-compress-all" + appendToVar NVCC_PREPEND_FLAGS "-Xfatbin=-compress-all" fi } preConfigureHooks+=(setupCUDAToolkitCompilers)