mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-15 17:48:01 +00:00
cudaPackages.cuda_nvcc: patch nvcc.profile
let nvcc know about cudart and the stub drivers; this way we do not need to search for cudart in the setupCudaHook
This commit is contained in:
parent
bfbfb34459
commit
35b1e5803a
@ -61,7 +61,30 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
|
||||
|
||||
cuda_nvcc = prev.cuda_nvcc.overrideAttrs (
|
||||
oldAttrs: {
|
||||
propagatedBuildInputs = [final.setupCudaHook];
|
||||
|
||||
outputs = oldAttrs.outputs ++ [ "lib" ];
|
||||
|
||||
postPatch =
|
||||
(oldAttrs.postPatch or "")
|
||||
+ ''
|
||||
substituteInPlace bin/nvcc.profile \
|
||||
--replace \
|
||||
'$(TOP)/lib' \
|
||||
"''${!outputLib}/lib"
|
||||
|
||||
cat << EOF >> bin/nvcc.profile
|
||||
LIBRARIES += "-L''${!outputBin}/nvvm/lib" "-L$static/lib" "-L${final.cuda_cudart.lib}/lib" "-L${final.cuda_cudart.lib}/lib/stubs"
|
||||
INCLUDES += "-I''${!outputDev}/include" "-I''${!outputBin}/nvvm/include" "-I${final.cuda_cudart.dev}/include"
|
||||
EOF
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = [ final.setupCudaHook ];
|
||||
|
||||
postInstall =
|
||||
(oldAttrs.postInstall or "")
|
||||
+ ''
|
||||
moveToOutput "nvvm" "''${!outputBin}"
|
||||
'';
|
||||
|
||||
meta = (oldAttrs.meta or {}) // {
|
||||
mainProgram = "nvcc";
|
||||
|
@ -14,6 +14,7 @@ let
|
||||
cudaVersion
|
||||
flags
|
||||
libcublas
|
||||
setupCudaHook
|
||||
;
|
||||
in
|
||||
backendStdenv.mkDerivation {
|
||||
|
@ -93,26 +93,6 @@ setupCUDAToolkitCompilers() {
|
||||
if [[ -z "${dontCompressFatbin-}" ]]; then
|
||||
export NVCC_PREPEND_FLAGS+=" -Xfatbin=-compress-all"
|
||||
fi
|
||||
|
||||
# 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
|
||||
if [[ ! -v cudaOutputToPath["cuda_cudart-out"] ]] ; then
|
||||
echo "setupCUDAToolkitCompilers: missing cudaPackages.cuda_cudart. This may become an an error in the future" >&2
|
||||
# exit 1
|
||||
fi
|
||||
for pkg in "${!cudaOutputToPath[@]}" ; do
|
||||
[[ ! "$pkg" = cuda_cudart* ]] && continue
|
||||
|
||||
local path="${cudaOutputToPath[$pkg]}"
|
||||
if [[ -d "$path/include" ]] ; then
|
||||
export NVCC_PREPEND_FLAGS+=" -I$path/include"
|
||||
fi
|
||||
if [[ -d "$path/lib" ]] ; then
|
||||
export NVCC_PREPEND_FLAGS+=" -L$path/lib"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
preConfigureHooks+=(setupCUDAToolkitCompilers)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user