================
@@ -915,48 +916,64 @@ void Clang::AddPreprocessingOptions(Compilation &C, const
JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_MP);
Args.AddLastArg(CmdArgs, options::OPT_MV);
- // Add offload include arguments specific for CUDA/HIP/SYCL. This must happen
- // before we -I or -include anything else, because we must pick up the
- // CUDA/HIP/SYCL headers from the particular CUDA/ROCm/SYCL installation,
- // rather than from e.g. /usr/local/include.
- if (JA.isOffloading(Action::OFK_Cuda))
- getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
- if (JA.isOffloading(Action::OFK_HIP))
- getToolChain().AddHIPIncludeArgs(Args, CmdArgs);
- if (JA.isOffloading(Action::OFK_SYCL))
- getToolChain().addSYCLIncludeArgs(Args, CmdArgs);
-
- // If we are offloading to a target via OpenMP we need to include the
- // openmp_wrappers folder which contains alternative system headers.
- if (JA.isDeviceOffloading(Action::OFK_OpenMP) &&
- !Args.hasArg(options::OPT_nostdinc) &&
- Args.hasFlag(options::OPT_offload_inc, options::OPT_no_offload_inc,
- true) &&
- getToolChain().getTriple().isGPU()) {
- if (!Args.hasArg(options::OPT_nobuiltininc)) {
- // Add openmp_wrappers/* to our system include path. This lets us wrap
- // standard library headers.
- SmallString<128> P(D.ResourceDir);
- llvm::sys::path::append(P, "include");
- llvm::sys::path::append(P, "openmp_wrappers");
- CmdArgs.push_back("-internal-isystem");
- CmdArgs.push_back(Args.MakeArgString(P));
+ bool UsesLLVMOffloading = Args.hasFlag(
+ options::OPT_foffload_via_llvm, options::OPT_fno_offload_via_llvm,
false);
+ bool UsesOffloadInclude =
+ Args.hasFlag(options::OPT_offload_inc, options::OPT_no_offload_inc,
true);
+ bool NoBuiltinInc = Args.hasArg(options::OPT_nobuiltininc);
+
+ // Add offload include arguments for CUDA/HIP when using LLVM offloading. We
+ // want to pull in our wrappers instead of the vendor headers.
+ if (UsesLLVMOffloading) {
+ if (UsesOffloadInclude && !NoBuiltinInc) {
+ CmdArgs.append({"-include", "__clang_gpu_device_functions.h"});
+ if (JA.isOffloading(Action::OFK_Cuda)) {
+ SmallString<128> OffloadCudaInclude(D.Dir);
+ llvm::sys::path::append(OffloadCudaInclude, "..", "include", "offload",
+ "cuda");
+ CmdArgs.append({"-internal-isystem",
+ Args.MakeArgString(OffloadCudaInclude), "-include"});
+ CmdArgs.push_back("cuda_runtime.h");
+ }
+ if (JA.isOffloading(Action::OFK_HIP) &&
+ !Args.hasArg(options::OPT_nohipwrapperinc)) {
+ SmallString<128> OffloadHIPInclude(D.Dir);
+ llvm::sys::path::append(OffloadHIPInclude, "..", "include", "offload");
+ CmdArgs.append({"-internal-isystem",
+ Args.MakeArgString(OffloadHIPInclude), "-include"});
+ CmdArgs.push_back("hip/hip_runtime.h");
----------------
jdoerfert wrote:
OFK just decides what the las CmdArgs is that we push. The rest is duplicated,
no?
https://github.com/llvm/llvm-project/pull/212373
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits