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