Skip to content

Commit 8ef0c44

Browse files
authored
[Driver][HIP] Do not pass -dependency-file flag for HIP Device offloading (llvm#125646) (llvm#616)
2 parents 1d7f33a + ab5962d commit 8ef0c44

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,21 +1019,23 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10191019
ArgM = ArgMD;
10201020

10211021
if (ArgM) {
1022-
// Determine the output location.
1023-
const char *DepFile;
1024-
if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
1025-
DepFile = MF->getValue();
1026-
C.addFailureResultFile(DepFile, &JA);
1027-
} else if (Output.getType() == types::TY_Dependencies) {
1028-
DepFile = Output.getFilename();
1029-
} else if (!ArgMD) {
1030-
DepFile = "-";
1031-
} else {
1032-
DepFile = getDependencyFileName(Args, Inputs);
1033-
C.addFailureResultFile(DepFile, &JA);
1022+
if (!JA.isDeviceOffloading(Action::OFK_HIP)) {
1023+
// Determine the output location.
1024+
const char *DepFile;
1025+
if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
1026+
DepFile = MF->getValue();
1027+
C.addFailureResultFile(DepFile, &JA);
1028+
} else if (Output.getType() == types::TY_Dependencies) {
1029+
DepFile = Output.getFilename();
1030+
} else if (!ArgMD) {
1031+
DepFile = "-";
1032+
} else {
1033+
DepFile = getDependencyFileName(Args, Inputs);
1034+
C.addFailureResultFile(DepFile, &JA);
1035+
}
1036+
CmdArgs.push_back("-dependency-file");
1037+
CmdArgs.push_back(DepFile);
10341038
}
1035-
CmdArgs.push_back("-dependency-file");
1036-
CmdArgs.push_back(DepFile);
10371039

10381040
bool HasTarget = false;
10391041
for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang -### -nogpuinc -nogpulib --offload-arch=gfx1030 --offload-arch=gfx1100 --offload-arch=gfx1101 --target=x86_64-linux-gnu -MD -MF tmp.d %s 2>&1 | FileCheck %s
2+
3+
// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1030"{{.*}}"-dependency-file" "tmp.d"
4+
// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1030"
5+
// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1100"{{.*}}"-dependency-file" "tmp.d"
6+
// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1100"
7+
// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1101"{{.*}}"-dependency-file" "tmp.d"
8+
// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1101"
9+
// CHECK: {{.*}}clang-offload-bundler
10+
// CHECK: {{.*}}clang{{.*}}"-target-cpu"{{.*}}"-dependency-file" "tmp.d"
11+
12+
void main(){}

0 commit comments

Comments
 (0)