Skip to content

Commit 9fc789d

Browse files
authored
[HIP] Use original file path for CUID (#107734)
to avoid being nondeterministic due to random path in distributed build.
1 parent 9de2603 commit 9fc789d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,10 +3034,7 @@ class OffloadingActionBuilder final {
30343034
else if (UseCUID == CUID_Hash) {
30353035
llvm::MD5 Hasher;
30363036
llvm::MD5::MD5Result Hash;
3037-
SmallString<256> RealPath;
3038-
llvm::sys::fs::real_path(IA->getInputArg().getValue(), RealPath,
3039-
/*expand_tilde=*/true);
3040-
Hasher.update(RealPath);
3037+
Hasher.update(IA->getInputArg().getValue());
30413038
for (auto *A : Args) {
30423039
if (A->getOption().matches(options::OPT_INPUT))
30433040
continue;

clang/test/Driver/hip-cuid-hash.hip

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Check CUID generated by hash.
22
// The same CUID is generated for the same file with the same options.
33

4+
// RUN: cd %S
5+
46
// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
57
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
6-
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
8+
// RUN: Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
79

810
// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
911
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
10-
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
12+
// RUN: Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
1113

1214
// RUN: FileCheck %s -check-prefixes=SAME -input-file %t.out
1315

@@ -16,15 +18,15 @@
1618

1719
// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu -DX=1 --no-offload-new-driver \
1820
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
19-
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
21+
// RUN: Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
2022

2123
// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu -DX=2 --no-offload-new-driver \
2224
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
23-
// RUN: %S/Inputs/../Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
25+
// RUN: Inputs/../Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
2426

2527
// RUN: FileCheck %s -check-prefixes=DIFF -input-file %t.out
2628

27-
// SAME: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID:[0-9a-f]+]]"
29+
// SAME: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID:3c08c1ef86ef439d]]"
2830
// SAME: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID]]"
2931

3032
// DIFF: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID:[0-9a-f]+]]"

0 commit comments

Comments
 (0)