Skip to content

Commit 6b55a14

Browse files
committed
Add machinery so that clang can find the hipstdar header
Change-Id: I35b85f4f67428de697901dc15583a3aeacb1578e
1 parent 6eb9d12 commit 6b55a14

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,26 +546,35 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs,
546546
}
547547

548548
const auto HandleHipStdPar = [=, &DriverArgs, &CC1Args]() {
549-
if (!hasHIPStdParLibrary()) {
549+
StringRef Inc = getIncludePath();
550+
auto &FS = D.getVFS();
551+
552+
if (!hasHIPStdParLibrary())
553+
if (!HIPStdParPathArg.empty() ||
554+
!FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) {
550555
D.Diag(diag::err_drv_no_hipstdpar_lib);
551556
return;
552557
}
553-
if (!HasRocThrustLibrary &&
554-
!D.getVFS().exists(getIncludePath() + "/thrust")) {
558+
if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) {
555559
D.Diag(diag::err_drv_no_hipstdpar_thrust_lib);
556560
return;
557561
}
558-
if (!HasRocPrimLibrary &&
559-
!D.getVFS().exists(getIncludePath() + "/rocprim")) {
562+
if (!HasRocPrimLibrary && !FS.exists(Inc + "/rocprim")) {
560563
D.Diag(diag::err_drv_no_hipstdpar_prim_lib);
561564
return;
562565
}
563-
564566
const char *ThrustPath;
565567
if (HasRocThrustLibrary)
566568
ThrustPath = DriverArgs.MakeArgString(HIPRocThrustPathArg);
567569
else
568-
ThrustPath = DriverArgs.MakeArgString(getIncludePath() + "/thrust");
570+
ThrustPath = DriverArgs.MakeArgString(Inc + "/thrust");
571+
572+
const char *HIPStdParPath;
573+
if (hasHIPStdParLibrary())
574+
HIPStdParPath = DriverArgs.MakeArgString(HIPStdParPathArg);
575+
else
576+
HIPStdParPath = DriverArgs.MakeArgString(StringRef(ThrustPath) +
577+
"/system/hip/hipstdpar");
569578

570579
const char *PrimPath;
571580
if (HasRocPrimLibrary)
@@ -574,7 +583,7 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs,
574583
PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim");
575584

576585
CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath,
577-
"-idirafter", DriverArgs.MakeArgString(HIPStdParPathArg),
586+
"-idirafter", HIPStdParPath,
578587
"-include", "hipstdpar_lib.hpp"});
579588
};
580589

clang/test/Driver/hipstdpar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// XFAIL: target={{.*}}-scei{{.*}}
66
// XFAIL: target={{.*}}-sie{{.*}}
77

8-
// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \
8+
// RUN: not %clang -### --hipstdpar --hipstdpar-path=/does/not/exist -nogpulib \
9+
// RUN: -nogpuinc --compile %s 2>&1 | \
910
// RUN: FileCheck --check-prefix=HIPSTDPAR-MISSING-LIB %s
1011
// RUN: %clang -### --hipstdpar --hipstdpar-path=%S/Inputs/hipstdpar \
1112
// RUN: --hipstdpar-thrust-path=%S/Inputs/hipstdpar/thrust \

0 commit comments

Comments
 (0)