Skip to content

Commit 7f9c518

Browse files
committedJan 31, 2018
[CUDA] Detect installation in PATH
If the CUDA toolkit is not installed to its default locations in /usr/local/cuda, the user is forced to specify --cuda-path. This is tedious and the driver can be smarter if well-known tools (like ptxas) can already be found in the PATH environment variable. Add option --cuda-path-ignore-env if the user wants to ignore set environment variables. Also use it in the tests to make sure the driver always finds the same CUDA installation, regardless of the user's environment. Differential Revision: https://reviews.llvm.org/D42642 llvm-svn: 323848
1 parent 5106d4d commit 7f9c518

File tree

14 files changed

+168
-34
lines changed

14 files changed

+168
-34
lines changed
 

Diff for: ‎clang/include/clang/Driver/Options.td

+2
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ def no_cuda_version_check : Flag<["--"], "no-cuda-version-check">,
556556
def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
557557
def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group<i_Group>,
558558
HelpText<"CUDA installation path">;
559+
def cuda_path_ignore_env : Joined<["--"], "cuda-path-ignore-env">, Group<i_Group>,
560+
HelpText<"Ignore environment variables to detect CUDA installation">;
559561
def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group<i_Group>,
560562
HelpText<"Path to ptxas (used for compiling CUDA code)">;
561563
def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,

Diff for: ‎clang/lib/Driver/ToolChains/Cuda.cpp

+50-15
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
//===----------------------------------------------------------------------===//
99

1010
#include "Cuda.h"
11-
#include "InputInfo.h"
1211
#include "CommonArgs.h"
12+
#include "InputInfo.h"
1313
#include "clang/Basic/Cuda.h"
14-
#include "clang/Config/config.h"
1514
#include "clang/Basic/VirtualFileSystem.h"
16-
#include "clang/Driver/Distro.h"
15+
#include "clang/Config/config.h"
1716
#include "clang/Driver/Compilation.h"
17+
#include "clang/Driver/Distro.h"
1818
#include "clang/Driver/Driver.h"
1919
#include "clang/Driver/DriverDiagnostic.h"
2020
#include "clang/Driver/Options.h"
2121
#include "llvm/Option/ArgList.h"
22+
#include "llvm/Support/FileSystem.h"
2223
#include "llvm/Support/Path.h"
24+
#include "llvm/Support/Program.h"
2325
#include <system_error>
2426

2527
using namespace clang::driver;
@@ -61,42 +63,75 @@ CudaInstallationDetector::CudaInstallationDetector(
6163
const Driver &D, const llvm::Triple &HostTriple,
6264
const llvm::opt::ArgList &Args)
6365
: D(D) {
64-
SmallVector<std::string, 4> CudaPathCandidates;
66+
struct Candidate {
67+
std::string Path;
68+
bool StrictChecking;
69+
70+
Candidate(std::string Path, bool StrictChecking = false)
71+
: Path(Path), StrictChecking(StrictChecking) {}
72+
};
73+
SmallVector<Candidate, 4> Candidates;
6574

6675
// In decreasing order so we prefer newer versions to older versions.
6776
std::initializer_list<const char *> Versions = {"8.0", "7.5", "7.0"};
6877

6978
if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
70-
CudaPathCandidates.push_back(
71-
Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ));
79+
Candidates.emplace_back(
80+
Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str());
7281
} else if (HostTriple.isOSWindows()) {
7382
for (const char *Ver : Versions)
74-
CudaPathCandidates.push_back(
83+
Candidates.emplace_back(
7584
D.SysRoot + "/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" +
7685
Ver);
7786
} else {
78-
CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
87+
if (!Args.hasArg(clang::driver::options::OPT_cuda_path_ignore_env)) {
88+
// Try to find ptxas binary. If the executable is located in a directory
89+
// called 'bin/', its parent directory might be a good guess for a valid
90+
// CUDA installation.
91+
// However, some distributions might installs 'ptxas' to /usr/bin. In that
92+
// case the candidate would be '/usr' which passes the following checks
93+
// because '/usr/include' exists as well. To avoid this case, we always
94+
// check for the directory potentially containing files for libdevice,
95+
// even if the user passes -nocudalib.
96+
if (llvm::ErrorOr<std::string> ptxas =
97+
llvm::sys::findProgramByName("ptxas")) {
98+
SmallString<256> ptxasAbsolutePath;
99+
llvm::sys::fs::real_path(*ptxas, ptxasAbsolutePath);
100+
101+
StringRef ptxasDir = llvm::sys::path::parent_path(ptxasAbsolutePath);
102+
if (llvm::sys::path::filename(ptxasDir) == "bin")
103+
Candidates.emplace_back(llvm::sys::path::parent_path(ptxasDir),
104+
/*StrictChecking=*/true);
105+
}
106+
}
107+
108+
Candidates.emplace_back(D.SysRoot + "/usr/local/cuda");
79109
for (const char *Ver : Versions)
80-
CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-" + Ver);
110+
Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
81111

82112
if (Distro(D.getVFS()).IsDebian())
83113
// Special case for Debian to have nvidia-cuda-toolkit work
84114
// out of the box. More info on http://bugs.debian.org/882505
85-
CudaPathCandidates.push_back(D.SysRoot + "/usr/lib/cuda");
115+
Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
86116
}
87117

88-
for (const auto &CudaPath : CudaPathCandidates) {
89-
if (CudaPath.empty() || !D.getVFS().exists(CudaPath))
118+
bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
119+
120+
for (const auto &Candidate : Candidates) {
121+
InstallPath = Candidate.Path;
122+
if (InstallPath.empty() || !D.getVFS().exists(InstallPath))
90123
continue;
91124

92-
InstallPath = CudaPath;
93-
BinPath = CudaPath + "/bin";
125+
BinPath = InstallPath + "/bin";
94126
IncludePath = InstallPath + "/include";
95127
LibDevicePath = InstallPath + "/nvvm/libdevice";
96128

97129
auto &FS = D.getVFS();
98130
if (!(FS.exists(IncludePath) && FS.exists(BinPath)))
99131
continue;
132+
bool CheckLibDevice = (!NoCudaLib || Candidate.StrictChecking);
133+
if (CheckLibDevice && !FS.exists(LibDevicePath))
134+
continue;
100135

101136
// On Linux, we have both lib and lib64 directories, and we need to choose
102137
// based on our triple. On MacOS, we have only a lib directory.
@@ -180,7 +215,7 @@ CudaInstallationDetector::CudaInstallationDetector(
180215

181216
// Check that we have found at least one libdevice that we can link in if
182217
// -nocudalib hasn't been specified.
183-
if (LibDeviceMap.empty() && !Args.hasArg(options::OPT_nocudalib))
218+
if (LibDeviceMap.empty() && !NoCudaLib)
184219
continue;
185220

186221
IsValid = true;

Diff for: ‎clang/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/bin/ptxas

Whitespace-only changes.

Diff for: ‎clang/test/Driver/Inputs/CUDA-symlinks/opt/cuda/bin/ptxas

Whitespace-only changes.

Diff for: ‎clang/test/Driver/Inputs/CUDA-symlinks/opt/cuda/include/.keep

Whitespace-only changes.

Diff for: ‎clang/test/Driver/Inputs/CUDA-symlinks/opt/cuda/lib/.keep

Whitespace-only changes.

Diff for: ‎clang/test/Driver/Inputs/CUDA-symlinks/opt/cuda/nvvm/libdevice/libdevice.compute_30.10.bc

Whitespace-only changes.

Diff for: ‎clang/test/Driver/Inputs/CUDA-symlinks/opt/cuda/nvvm/libdevice/libdevice.compute_35.10.bc

Whitespace-only changes.

Diff for: ‎clang/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../opt/cuda/bin/ptxas

Diff for: ‎clang/test/Driver/Inputs/CUDA/usr/local/cuda/bin/ptxas

Whitespace-only changes.

Diff for: ‎clang/test/Driver/cuda-detect-path.cu

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// REQUIRES: clang-driver
2+
// REQUIRES: x86-registered-target
3+
// REQUIRES: nvptx-registered-target
4+
// This tests uses the PATH environment variable.
5+
// REQUIRES: !system-windows
6+
7+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
8+
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
9+
// RUN: 2>&1 | FileCheck %s
10+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
11+
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
12+
// RUN: 2>&1 | FileCheck %s
13+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
14+
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
15+
// RUN: 2>&1 | FileCheck %s
16+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
17+
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
18+
// RUN: 2>&1 | FileCheck %s
19+
20+
21+
// Check that we follow ptxas binaries that are symlinks.
22+
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
23+
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
24+
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
25+
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
26+
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
27+
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
28+
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
29+
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
30+
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
31+
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
32+
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
33+
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
34+
35+
36+
// We only take a CUDA installation from PATH if it contains libdevice.
37+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
38+
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
39+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
40+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
41+
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
42+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
43+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
44+
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
45+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
46+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
47+
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
48+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
49+
50+
// We even require libdevice if -nocudalib is passed to avoid false positives
51+
// if the distribution merges CUDA into /usr and ptxas ends up /usr/bin.
52+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
53+
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there -nocudalib \
54+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
55+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
56+
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there -nocudalib \
57+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
58+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
59+
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there -nocudalib \
60+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
61+
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
62+
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there -nocudalib \
63+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
64+
65+
66+
// Check that the CUDA installation in PATH is not taken when passing
67+
// the option --cuda-path-ignore-env.
68+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
69+
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
70+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
71+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
72+
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
73+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
74+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
75+
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
76+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
77+
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
78+
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
79+
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
80+
81+
// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
82+
// SYMLINKS: Found CUDA installation: {{.*}}/Inputs/CUDA-symlinks/opt/cuda
83+
// NOCUDA-NOT: Found CUDA installation:

Diff for: ‎clang/test/Driver/cuda-detect.cu

+19-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
//
55
// Check that we properly detect CUDA installation.
66
// RUN: %clang -v --target=i386-unknown-linux \
7-
// RUN: --sysroot=%S/no-cuda-there 2>&1 | FileCheck %s -check-prefix NOCUDA
7+
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
88
// RUN: %clang -v --target=i386-apple-macosx \
9-
// RUN: --sysroot=%S/no-cuda-there 2>&1 | FileCheck %s -check-prefix NOCUDA
9+
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
10+
// RUN: %clang -v --target=x86_64-unknown-linux \
11+
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
12+
// RUN: %clang -v --target=x86_64-apple-macosx \
13+
// RUN: --sysroot=%S/no-cuda-there --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
14+
1015

1116
// RUN: %clang -v --target=i386-unknown-linux \
1217
// RUN: --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
@@ -20,15 +25,23 @@
2025

2126
// Check that we don't find a CUDA installation without libdevice ...
2227
// RUN: %clang -v --target=i386-unknown-linux \
23-
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NOCUDA
28+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
2429
// RUN: %clang -v --target=i386-apple-macosx \
25-
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NOCUDA
30+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
31+
// RUN: %clang -v --target=x86_64-unknown-linux \
32+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
33+
// RUN: %clang -v --target=x84_64-apple-macosx \
34+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NOCUDA
2635

2736
// ... unless the user doesn't need libdevice
2837
// RUN: %clang -v --target=i386-unknown-linux -nocudalib \
29-
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE
38+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE
3039
// RUN: %clang -v --target=i386-apple-macosx -nocudalib \
31-
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE
40+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE
41+
// RUN: %clang -v --target=x86_64-unknown-linux -nocudalib \
42+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE
43+
// RUN: %clang -v --target=x86_64-apple-macosx -nocudalib \
44+
// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice --cuda-path-ignore-env 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE
3245

3346

3447
// Make sure we map libdevice bitcode files to proper GPUs. These

Diff for: ‎clang/test/Driver/cuda-not-found.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Check that we raise an error if we're trying to compile CUDA code but can't
44
// find a CUDA install, unless -nocudainc was passed.
55

6-
// RUN: %clang -### --sysroot=%s/no-cuda-there %s 2>&1 | FileCheck %s --check-prefix ERR
6+
// RUN: %clang -### --sysroot=%s/no-cuda-there --cuda-path-ignore-env %s 2>&1 | FileCheck %s --check-prefix ERR
77
// RUN: %clang -### --cuda-path=%s/no-cuda-there %s 2>&1 | FileCheck %s --check-prefix ERR
88
// ERR: cannot find CUDA installation
99

10-
// RUN: %clang -### -nocudainc --sysroot=%s/no-cuda-there %s 2>&1 | FileCheck %s --check-prefix OK
10+
// RUN: %clang -### -nocudainc --sysroot=%s/no-cuda-there --cuda-path-ignore-env %s 2>&1 | FileCheck %s --check-prefix OK
1111
// RUN: %clang -### -nocudainc --cuda-path=%s/no-cuda-there %s 2>&1 | FileCheck %s --check-prefix OK
1212
// OK-NOT: cannot find CUDA installation

Diff for: ‎clang/test/Driver/cuda-version-check.cu

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,50 @@
22
// REQUIRES: x86-registered-target
33
// REQUIRES: nvptx-registered-target
44

5-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_20 --sysroot=%S/Inputs/CUDA 2>&1 %s | \
5+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_20 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
66
// RUN: FileCheck %s --check-prefix=OK
7-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_20 --sysroot=%S/Inputs/CUDA_80 2>&1 %s | \
7+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda 2>&1 %s | \
88
// RUN: FileCheck %s --check-prefix=OK
9-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --sysroot=%S/Inputs/CUDA_80 2>&1 %s | \
9+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda 2>&1 %s | \
1010
// RUN: FileCheck %s --check-prefix=OK
1111

1212
// The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
13-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --sysroot=%S/Inputs/CUDA 2>&1 %s | \
13+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
1414
// RUN: FileCheck %s --check-prefix=ERR_SM60
1515

1616
// This should only complain about sm_60, not sm_35.
1717
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-gpu-arch=sm_35 \
18-
// RUN: --sysroot=%S/Inputs/CUDA 2>&1 %s | \
18+
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
1919
// RUN: FileCheck %s --check-prefix=ERR_SM60 --check-prefix=OK_SM35
2020

2121
// We should get two errors here, one for sm_60 and one for sm_61.
2222
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-gpu-arch=sm_61 \
23-
// RUN: --sysroot=%S/Inputs/CUDA 2>&1 %s | \
23+
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
2424
// RUN: FileCheck %s --check-prefix=ERR_SM60 --check-prefix=ERR_SM61
2525

2626
// We should still get an error if we pass -nocudainc, because this compilation
2727
// would invoke ptxas, and we do a version check on that, too.
28-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 -nocudainc --sysroot=%S/Inputs/CUDA 2>&1 %s | \
28+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
2929
// RUN: FileCheck %s --check-prefix=ERR_SM60
3030

3131
// If with -nocudainc and -E, we don't touch the CUDA install, so we
3232
// shouldn't get an error.
3333
// RUN: %clang --target=x86_64-linux -v -### -E --cuda-device-only --cuda-gpu-arch=sm_60 -nocudainc \
34-
// RUN: --sysroot=%S/Inputs/CUDA 2>&1 %s | \
34+
// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
3535
// RUN: FileCheck %s --check-prefix=OK
3636

3737
// --no-cuda-version-check should suppress all of these errors.
38-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --sysroot=%S/Inputs/CUDA 2>&1 \
38+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 \
3939
// RUN: --no-cuda-version-check %s | \
4040
// RUN: FileCheck %s --check-prefix=OK
4141

4242
// We need to make sure the version check is done only for the device toolchain,
4343
// therefore we should not get an error in host-only mode. We use the -S here
4444
// to avoid the error being produced in case by the assembler tool, which does
4545
// the same check.
46-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-host-only --sysroot=%S/Inputs/CUDA -S 2>&1 %s | \
46+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-host-only --cuda-path=%S/Inputs/CUDA/usr/local/cuda -S 2>&1 %s | \
4747
// RUN: FileCheck %s --check-prefix=OK
48-
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-device-only --sysroot=%S/Inputs/CUDA -S 2>&1 %s | \
48+
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-device-only --cuda-path=%S/Inputs/CUDA/usr/local/cuda -S 2>&1 %s | \
4949
// RUN: FileCheck %s --check-prefix=ERR_SM60
5050

5151
// OK-NOT: error: GPU arch

0 commit comments

Comments
 (0)
Please sign in to comment.