@@ -32,24 +32,28 @@ using namespace llvm::opt;
32
32
33
33
// Parses the contents of version.txt in an CUDA installation. It should
34
34
// contain one line of the from e.g. "CUDA Version 7.5.2".
35
- static CudaVersion ParseCudaVersionFile (const Driver &D, llvm::StringRef V) {
35
+ void CudaInstallationDetector::ParseCudaVersionFile (llvm::StringRef V) {
36
+ Version = CudaVersion::UNKNOWN;
36
37
if (!V.startswith (" CUDA Version " ))
37
- return CudaVersion::UNKNOWN ;
38
+ return ;
38
39
V = V.substr (strlen (" CUDA Version " ));
39
40
SmallVector<StringRef,4 > VersionParts;
40
41
V.split (VersionParts, ' .' );
41
42
if (VersionParts.size () < 2 )
42
- return CudaVersion::UNKNOWN ;
43
- std::string MajorMinor = join_items (" ." , VersionParts[0 ], VersionParts[1 ]);
44
- CudaVersion Version = CudaStringToVersion (MajorMinor );
43
+ return ;
44
+ DetectedVersion = join_items (" ." , VersionParts[0 ], VersionParts[1 ]);
45
+ Version = CudaStringToVersion (DetectedVersion );
45
46
if (Version != CudaVersion::UNKNOWN)
46
- return Version ;
47
+ return ;
47
48
48
- // Issue a warning and assume that the version we've found is compatible with
49
- // the latest version we support.
50
- D.Diag (diag::warn_drv_unknown_cuda_version)
51
- << MajorMinor << CudaVersionToString (CudaVersion::LATEST);
52
- return CudaVersion::LATEST;
49
+ Version = CudaVersion::LATEST;
50
+ DetectedVersionIsNotSupported = true ;
51
+ }
52
+
53
+ void CudaInstallationDetector::WarnIfUnsupportedVersion () {
54
+ if (DetectedVersionIsNotSupported)
55
+ D.Diag (diag::warn_drv_unknown_cuda_version)
56
+ << DetectedVersion << CudaVersionToString (Version);
53
57
}
54
58
55
59
CudaInstallationDetector::CudaInstallationDetector (
@@ -147,7 +151,7 @@ CudaInstallationDetector::CudaInstallationDetector(
147
151
// version.txt isn't present.
148
152
Version = CudaVersion::CUDA_70;
149
153
} else {
150
- Version = ParseCudaVersionFile (D, (*VersionFile)->getBuffer ());
154
+ ParseCudaVersionFile ((*VersionFile)->getBuffer ());
151
155
}
152
156
153
157
if (Version >= CudaVersion::CUDA_90) {
@@ -565,8 +569,10 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
565
569
const Action::OffloadKind OK)
566
570
: ToolChain(D, Triple, Args), HostTC(HostTC),
567
571
CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
568
- if (CudaInstallation.isValid ())
572
+ if (CudaInstallation.isValid ()) {
573
+ CudaInstallation.WarnIfUnsupportedVersion ();
569
574
getProgramPaths ().push_back (CudaInstallation.getBinPath ());
575
+ }
570
576
// Lookup binaries into the driver directory, this is used to
571
577
// discover the clang-offload-bundler executable.
572
578
getProgramPaths ().push_back (getDriver ().Dir );
0 commit comments