Author: Joseph Huber Date: 2023-08-08T19:07:47-05:00 New Revision: 61709bbae37af4e01cf93c6d112ba984bbd9a7ea
URL: https://github.com/llvm/llvm-project/commit/61709bbae37af4e01cf93c6d112ba984bbd9a7ea DIFF: https://github.com/llvm/llvm-project/commit/61709bbae37af4e01cf93c6d112ba984bbd9a7ea.diff LOG: [OpenMP] Ensure wrapper headers are included on both host and device For the in-progress GPU `libc` project we are relying on overlay headers to handle the interfacing between the `libc` project and the host `libc`. We need this to be included on both the host and device so they agree one what is present on the device, otherwise we will end up with random errors. For whatever reason this was not being included on the host although it previously worked. This patch ensures that it's included on both. Reviewed By: yaxunl Differential Revision: https://reviews.llvm.org/D157438 Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/gpu-libc-headers.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c5155735000490..1a76e6d8d76bce 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1183,14 +1183,13 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, // with ones created by the 'libc' project if present. if (!Args.hasArg(options::OPT_nostdinc) && !Args.hasArg(options::OPT_nogpuinc) && - !Args.hasArg(options::OPT_nobuiltininc) && - (getToolChain().getTriple().isNVPTX() || - getToolChain().getTriple().isAMDGCN())) { - + !Args.hasArg(options::OPT_nobuiltininc)) { // Without an offloading language we will include these headers directly. // Offloading languages will instead only use the declarations stored in // the resource directory at clang/lib/Headers/llvm_libc_wrappers. - if (C.getActiveOffloadKinds() == Action::OFK_None) { + if ((getToolChain().getTriple().isNVPTX() || + getToolChain().getTriple().isAMDGCN()) && + C.getActiveOffloadKinds() == Action::OFK_None) { SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir)); llvm::sys::path::append(P, "include"); llvm::sys::path::append(P, "gpu-none-llvm"); diff --git a/clang/test/Driver/gpu-libc-headers.c b/clang/test/Driver/gpu-libc-headers.c index c6361b4b892d39..74e9a764dfcb35 100644 --- a/clang/test/Driver/gpu-libc-headers.c +++ b/clang/test/Driver/gpu-libc-headers.c @@ -8,6 +8,7 @@ // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70 \ // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS // CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./" +// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./" // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \ // RUN: -nogpuinc %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS-DISABLED _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits