Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ CudaInstallationDetector::CudaInstallationDetector(
Candidates.emplace_back(
Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str());
} else if (HostTriple.isOSWindows()) {
// CUDA_PATH is set by the installer, prefer it over other versions that
// might be present on the system.
if (const char *CudaPathEnvVar = ::getenv("CUDA_PATH"))
Candidates.emplace_back(CudaPathEnvVar);

for (const char *Ver : Versions)
Candidates.emplace_back(
D.SysRoot + "/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" +
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Driver/cuda-windows-cuda-path.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///
/// Make sure that CUDA_PATH is picked up correctly when looking for CUDA
/// instalation.
///

// REQUIRES: system-windows
// RUN: env CUDA_PATH=%S\Inputs\CUDA_111\usr\local\cuda %clang -fsycl \
// RUN: -fsycl-targets=nvptx64-nvidia-cuda -### -v %s 2>&1 | \
// RUN: FileCheck %s

// CHECK: Found CUDA installation: {{.*}}Inputs\CUDA_111\usr\local\cuda, version 11.1

int main() {}