[PATCH] D23341: [CUDA] Include CUDA headers before anything else.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 15 13:46:57 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL278734: [CUDA] Include CUDA headers before anything else. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23341?vs=67439&id=68072#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23341

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/lib/Driver/Tools.cpp
===================================================================
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -410,6 +410,13 @@
     }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+    getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@
     // For IAMCU add special include arguments.
     getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-    getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
Index: cfe/trunk/test/Driver/cuda-detect.cu
===================================================================
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23341.68072.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160815/05259c16/attachment.bin>


More information about the cfe-commits mailing list