]> granicus.if.org Git - clang/commitdiff
[CUDA] Raise an error if the CUDA install can't be found.
authorJustin Lebar <jlebar@google.com>
Sat, 16 Apr 2016 00:11:11 +0000 (00:11 +0000)
committerJustin Lebar <jlebar@google.com>
Sat, 16 Apr 2016 00:11:11 +0000 (00:11 +0000)
Summary:
Without this change, we silently proceed on without including
__clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
you say you're compiling CUDA code, but e.g. __device__ is not defined!

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19180

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266496 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/ToolChains.cpp

index ce455ae9768a07e6ef6038dbcd7f0556950c6e2b..2eab9b6428d7e7156c5a5b6426e5cc801f6c0a1d 100644 (file)
@@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"language not recognized: '%0'">;
 def err_drv_invalid_arch_name : Error<
   "invalid arch name '%0'">;
 def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">;
+def err_drv_no_cuda_installation : Error<
+  "cannot find CUDA installation.  Provide its path via --cuda-path, or pass "
+  "-nocudainc to build without CUDA includes.">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<
index 902338b2884136735458eb81c39b20361be349c7..8420fd8fbd6e8b4451d9a029e4de4506b52ab930 100644 (file)
@@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
   if (DriverArgs.hasArg(options::OPT_nocudainc))
     return;
 
-  if (CudaInstallation.isValid()) {
-    addSystemInclude(DriverArgs, CC1Args, CudaInstallation.getIncludePath());
-    CC1Args.push_back("-include");
-    CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
+  if (!CudaInstallation.isValid()) {
+    getDriver().Diag(diag::err_drv_no_cuda_installation);
+    return;
   }
+
+  addSystemInclude(DriverArgs, CC1Args, CudaInstallation.getIncludePath());
+  CC1Args.push_back("-include");
+  CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
 }
 
 bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }