Skip to content

Commit 12e8e0b

Browse files
authored
[AMDGPU] Correctly use the auxiliary toolchain to include libc++ (#109366)
Summary: Now that we have a functional build for `libc++` on the GPU, it will now find the target specific headers in `include/amdgcn-amd-amdhsa`. This is a problem for offloading via OpenMP because we need the CPU and GPU headers to match exactly. All the other toolchains forward this correctly except the AMDGPU OpenMP one, fix this by overriding it to use the host toolchain instead of the device one, so the triple is not returned as `amdgcn-amd-amdhsa`.
1 parent 8db97ae commit 12e8e0b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ AMDGPUOpenMPToolChain::GetCXXStdlibType(const ArgList &Args) const {
120120
return HostTC.GetCXXStdlibType(Args);
121121
}
122122

123+
void AMDGPUOpenMPToolChain::AddClangCXXStdlibIncludeArgs(
124+
const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1Args) const {
125+
HostTC.AddClangCXXStdlibIncludeArgs(Args, CC1Args);
126+
}
127+
123128
void AMDGPUOpenMPToolChain::AddClangSystemIncludeArgs(
124129
const ArgList &DriverArgs, ArgStringList &CC1Args) const {
125130
HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);

clang/lib/Driver/ToolChains/AMDGPUOpenMP.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUOpenMPToolChain final
4242
Action::OffloadKind DeviceOffloadKind) const override;
4343
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
4444
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
45+
void AddClangCXXStdlibIncludeArgs(
46+
const llvm::opt::ArgList &Args,
47+
llvm::opt::ArgStringList &CC1Args) const override;
4548
void
4649
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
4750
llvm::opt::ArgStringList &CC1Args) const override;

clang/test/Driver/amdgpu-openmp-toolchain.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-WARN-ATOMIC
7878
// CHECK-WARN-ATOMIC-NOT: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-Werror=atomic-alignment"
7979
// CHECK-WARN-ATOMIC: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-Werror=atomic-alignment"
80+
81+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp --offload-arch=gfx803 \
82+
// RUN: -stdlib=libc++ -nogpulib %s 2>&1 | FileCheck %s --check-prefix=LIBCXX
83+
// LIBCXX-NOT: include/amdgcn-amd-amdhsa/c++/v1

0 commit comments

Comments
 (0)