jdenny created this revision. jdenny added reviewers: ABataev, Hahnfeld, tra, sylvestre.ledru. Herald added a subscriber: guansong.
D40453 <https://reviews.llvm.org/D40453> (r319317) was meant to handle nvidia-cuda-toolkit's split CUDA installation in Debian. This patch addresses two issues left unresolved by D40453 <https://reviews.llvm.org/D40453>, at least on my Ubuntu 18.04.1 installation: 1. IsDebian() doesn't include IsUbuntu(), so D40453 <https://reviews.llvm.org/D40453> doesn't help me. 2. When `--cuda-path=/usr` is meant to find the nvidia-cuda-toolkit installation, the split installation isn't handled. Issue 2 occurs when I follow step 4 in the following guide to rebuild the OpenMP runtime with clang to build bitcode libraries: https://www.hahnjo.de/blog/2018/10/08/clang-7.0-openmp-offloading-nvidia.html The reason is that `libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake` then specifies `--cuda-path=/usr` when testing clang, but it would need to leave `--cuda-path` unspecified to trigger D40453 <https://reviews.llvm.org/D40453>'s fix. Perhaps that cmake file could be adjusted instead, but the fix in this patch is more general. Obviously, this isn't the first time this issue has been discussed, but googling didn't reveal to me a definitive answer on the path forward. Proposing this patch seems like the easiest way to ask. Repository: rC Clang https://reviews.llvm.org/D55269 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 @@ -80,9 +80,19 @@ // In decreasing order so we prefer newer versions to older versions. std::initializer_list<const char *> Versions = {"8.0", "7.5", "7.0"}; + // Special case for Debian to have nvidia-cuda-toolkit work + // out of the box. More info on http://bugs.debian.org/882505 + const char *NvidiaCudaToolkit = + (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu()) + ? "/usr/lib/cuda" + : nullptr; + if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) { - Candidates.emplace_back( - Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str()); + std::string CudaPath = + Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str(); + Candidates.emplace_back(CudaPath); + if (NvidiaCudaToolkit && CudaPath == "/usr") + Candidates.emplace_back(D.SysRoot + NvidiaCudaToolkit); } else if (HostTriple.isOSWindows()) { for (const char *Ver : Versions) Candidates.emplace_back( @@ -114,10 +124,8 @@ for (const char *Ver : Versions) Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver); - if (Distro(D.getVFS()).IsDebian()) - // Special case for Debian to have nvidia-cuda-toolkit work - // out of the box. More info on http://bugs.debian.org/882505 - Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda"); + if (NvidiaCudaToolkit) + Candidates.emplace_back(D.SysRoot + NvidiaCudaToolkit); } bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
Index: clang/lib/Driver/ToolChains/Cuda.cpp =================================================================== --- clang/lib/Driver/ToolChains/Cuda.cpp +++ clang/lib/Driver/ToolChains/Cuda.cpp @@ -80,9 +80,19 @@ // In decreasing order so we prefer newer versions to older versions. std::initializer_list<const char *> Versions = {"8.0", "7.5", "7.0"}; + // Special case for Debian to have nvidia-cuda-toolkit work + // out of the box. More info on http://bugs.debian.org/882505 + const char *NvidiaCudaToolkit = + (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu()) + ? "/usr/lib/cuda" + : nullptr; + if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) { - Candidates.emplace_back( - Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str()); + std::string CudaPath = + Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str(); + Candidates.emplace_back(CudaPath); + if (NvidiaCudaToolkit && CudaPath == "/usr") + Candidates.emplace_back(D.SysRoot + NvidiaCudaToolkit); } else if (HostTriple.isOSWindows()) { for (const char *Ver : Versions) Candidates.emplace_back( @@ -114,10 +124,8 @@ for (const char *Ver : Versions) Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver); - if (Distro(D.getVFS()).IsDebian()) - // Special case for Debian to have nvidia-cuda-toolkit work - // out of the box. More info on http://bugs.debian.org/882505 - Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda"); + if (NvidiaCudaToolkit) + Candidates.emplace_back(D.SysRoot + NvidiaCudaToolkit); } bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits