Skip to content

Commit b0c145a

Browse files
authored
[SYCL] Use CUDA_PATH as a candidate for path discovery (#5194)
1 parent 7068457 commit b0c145a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ CudaInstallationDetector::CudaInstallationDetector(
136136
Candidates.emplace_back(
137137
Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str());
138138
} else if (HostTriple.isOSWindows()) {
139+
// CUDA_PATH is set by the installer, prefer it over other versions that
140+
// might be present on the system.
141+
if (const char *CudaPathEnvVar = ::getenv("CUDA_PATH"))
142+
Candidates.emplace_back(CudaPathEnvVar);
143+
139144
for (const char *Ver : Versions)
140145
Candidates.emplace_back(
141146
D.SysRoot + "/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" +
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
///
2+
/// Make sure that CUDA_PATH is picked up correctly when looking for CUDA
3+
/// installation.
4+
///
5+
6+
// REQUIRES: system-windows
7+
// RUN: env CUDA_PATH=%S\Inputs\CUDA_111\usr\local\cuda %clang -fsycl \
8+
// RUN: -fsycl-targets=nvptx64-nvidia-cuda -### -v %s 2>&1 | \
9+
// RUN: FileCheck %s
10+
11+
// CHECK: Found CUDA installation: {{.*}}Inputs\CUDA_111\usr\local\cuda, version 11.1

0 commit comments

Comments
 (0)