r278734 - [CUDA] Include CUDA headers before anything else.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 15 13:38:52 PDT 2016
Author: jlebar
Date: Mon Aug 15 15:38:52 2016
New Revision: 278734
URL: http://llvm.org/viewvc/llvm-project?rev=278734&view=rev
Log:
[CUDA] Include CUDA headers before anything else.
Summary:
There's no point to --cuda-path if we then go and include /usr/include
first. And if you install the right packages, Ubuntu will install (very
old) CUDA headers there.
Reviewers: tra
Subscribers: cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D23341
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cuda-detect.cu
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=278734&r1=278733&r2=278734&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Aug 15 15:38:52 2016
@@ -410,6 +410,13 @@ void Clang::AddPreprocessingOptions(Comp
}
}
+ // 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 @@ void Clang::AddPreprocessingOptions(Comp
// 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.
Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278734&r1=278733&r2=278734&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Mon Aug 15 15:38:52 2016
@@ -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"
More information about the cfe-commits
mailing list