Skip to content

Commit 61709bb

Browse files
committed
[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
1 parent a7f0195 commit 61709bb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,14 +1183,13 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
11831183
// with ones created by the 'libc' project if present.
11841184
if (!Args.hasArg(options::OPT_nostdinc) &&
11851185
!Args.hasArg(options::OPT_nogpuinc) &&
1186-
!Args.hasArg(options::OPT_nobuiltininc) &&
1187-
(getToolChain().getTriple().isNVPTX() ||
1188-
getToolChain().getTriple().isAMDGCN())) {
1189-
1186+
!Args.hasArg(options::OPT_nobuiltininc)) {
11901187
// Without an offloading language we will include these headers directly.
11911188
// Offloading languages will instead only use the declarations stored in
11921189
// the resource directory at clang/lib/Headers/llvm_libc_wrappers.
1193-
if (C.getActiveOffloadKinds() == Action::OFK_None) {
1190+
if ((getToolChain().getTriple().isNVPTX() ||
1191+
getToolChain().getTriple().isAMDGCN()) &&
1192+
C.getActiveOffloadKinds() == Action::OFK_None) {
11941193
SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
11951194
llvm::sys::path::append(P, "include");
11961195
llvm::sys::path::append(P, "gpu-none-llvm");

clang/test/Driver/gpu-libc-headers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70 \
99
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
1010
// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
11+
// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
1112

1213
// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
1314
// RUN: -nogpuinc %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS-DISABLED

0 commit comments

Comments
 (0)