diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -810,6 +810,12 @@ if (!CudaTC) { CudaTC = std::make_unique( *this, *CudaTriple, *HostTC, C.getInputArgs()); + + // Emit a warning if the detected CUDA version is too new. + CudaInstallationDetector &CudaInstallation = + static_cast(*CudaTC).CudaInstallation; + if (CudaInstallation.isValid()) + CudaInstallation.WarnIfUnsupportedVersion(); } C.addOffloadDeviceToolChain(CudaTC.get(), OFK); } else if (IsHIP) { diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -704,10 +704,8 @@ const ArgList &Args, bool Freestanding = false) : ToolChain(D, Triple, Args), CudaInstallation(D, HostTriple, Args), Freestanding(Freestanding) { - if (CudaInstallation.isValid()) { - CudaInstallation.WarnIfUnsupportedVersion(); + if (CudaInstallation.isValid()) getProgramPaths().push_back(std::string(CudaInstallation.getBinPath())); - } // Lookup binaries into the driver directory, this is used to // discover the 'nvptx-arch' executable. getProgramPaths().push_back(getDriver().Dir);