tra created this revision. tra added reviewers: yaxunl, emankov, hans. Herald added a subscriber: bixia. Herald added a project: clang. tra requested review of this revision.
CUDA-11.1 does not carry version.txt which causes clang to assume that it's CUDA-7.0, which used to be the only CUDA version w/o version.txt. In order to tell CUDA-7.0 apart from the new versions, clang now probes for the presence of libdevice.10.bc which is not present in the old CUDA versions. This should keep Clang working for CUDA-11.1. Bug: https://bugs.llvm.org/show_bug.cgi?id=47332 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D89752 Files: clang/lib/Driver/ToolChains/Cuda.cpp Index: clang/lib/Driver/ToolChains/Cuda.cpp =================================================================== --- clang/lib/Driver/ToolChains/Cuda.cpp +++ clang/lib/Driver/ToolChains/Cuda.cpp @@ -155,9 +155,14 @@ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile = FS.getBufferForFile(InstallPath + "/version.txt"); if (!VersionFile) { - // CUDA 7.0 doesn't have a version.txt, so guess that's our version if - // version.txt isn't present. - Version = CudaVersion::CUDA_70; + // CUDA 7.0 and CUDA 11.1+ do not have version.txt file. + // Use libdevice file to distinguish 7.0 from the new versions. + if (FS.exists(LibDevicePath + "/libdevice.10.bc")) { + Version = CudaVersion::LATEST; + DetectedVersionIsNotSupported = Version > CudaVersion::LATEST_SUPPORTED; + } else { + Version = CudaVersion::CUDA_70; + } } else { ParseCudaVersionFile((*VersionFile)->getBuffer()); }
Index: clang/lib/Driver/ToolChains/Cuda.cpp =================================================================== --- clang/lib/Driver/ToolChains/Cuda.cpp +++ clang/lib/Driver/ToolChains/Cuda.cpp @@ -155,9 +155,14 @@ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile = FS.getBufferForFile(InstallPath + "/version.txt"); if (!VersionFile) { - // CUDA 7.0 doesn't have a version.txt, so guess that's our version if - // version.txt isn't present. - Version = CudaVersion::CUDA_70; + // CUDA 7.0 and CUDA 11.1+ do not have version.txt file. + // Use libdevice file to distinguish 7.0 from the new versions. + if (FS.exists(LibDevicePath + "/libdevice.10.bc")) { + Version = CudaVersion::LATEST; + DetectedVersionIsNotSupported = Version > CudaVersion::LATEST_SUPPORTED; + } else { + Version = CudaVersion::CUDA_70; + } } else { ParseCudaVersionFile((*VersionFile)->getBuffer()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits