diff options
author | Brad King <brad.king@kitware.com> | 2018-05-11 12:37:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-05-11 12:49:10 (GMT) |
commit | a170a59a582ec4e5d65d2e66503a3838982b7de0 (patch) | |
tree | a4447d6ec70ec967950a51e35f38277ec67eb491 /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | ad83aa0f3d97ab9a02a14e0cd9f85f5cab2b2668 (diff) | |
download | CMake-a170a59a582ec4e5d65d2e66503a3838982b7de0.zip CMake-a170a59a582ec4e5d65d2e66503a3838982b7de0.tar.gz CMake-a170a59a582ec4e5d65d2e66503a3838982b7de0.tar.bz2 |
VS: Link CUDA binaries with the device runtime library 'cudadevrt'
According to https://docs.nvidia.com/cuda/nvrtc/index.html there are
some cases where a CUDA binary "...must be linked against the CUDA
device runtime (cudadevrt) library". When `nvcc` drives linking it
automatically links to runtime libraries as follows:
* -cudart=none: None
* -cudart=shared: -lcudadevrt -lcudart
* -cudart=static: -lcudadevrt -lcudart_static
The `cudadevrt` library is the cuda device runtime library. It is
always static so passing it to the linker when not necessary does
not hurt anything.
With Ninja and Makefile generators, we detect `cudadevrt` and either
`cudart` or `cudart_static` libraries implied by `nvcc` and then add
them to link lines driven by a host compiler. However, this does not
work with the VS generator because the CUDA Toolkit Visual Studio
integration does not use `nvcc` to link binaries and instead uses
`link.exe` directly.
Visual Studio project files (`.vcxproj`) for CUDA are expected to
explicitly list the needed runtime libraries. Our VS generator already
adds `cudart.lib` or `cudart_static.lib` based on the `-cudart=` flag.
Update it to also add `cudadevrt.lib` as nvcc does.
Fixes: #17988
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cfdf2d8..d90d754 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3298,9 +3298,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( "CUDA") != linkClosure->Languages.end()) { switch (this->CudaOptions[config]->GetCudaRuntime()) { case cmVisualStudioGeneratorOptions::CudaRuntimeStatic: + libVec.push_back("cudadevrt.lib"); libVec.push_back("cudart_static.lib"); break; case cmVisualStudioGeneratorOptions::CudaRuntimeShared: + libVec.push_back("cudadevrt.lib"); libVec.push_back("cudart.lib"); break; case cmVisualStudioGeneratorOptions::CudaRuntimeNone: |