Skip to content

Commit 2674034

Browse files
authored
Reland "[HIP] Use original file path for CUID" (#111885)
This patch fixes the buildbots failure of lit tests on MacOS. Since clang driver options depend on toolchain, we cannot hardcode CUID hash. On MacOS there is an extra -mlinker-version= option.
1 parent 2c8b2dc commit 2674034

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,7 @@ std::string CUIDOptions::getCUID(StringRef InputFile,
226226
else if (UseCUID == Kind::Hash) {
227227
llvm::MD5 Hasher;
228228
llvm::MD5::MD5Result Hash;
229-
SmallString<256> RealPath;
230-
llvm::sys::fs::real_path(InputFile, RealPath,
231-
/*expand_tilde=*/true);
232-
Hasher.update(RealPath);
229+
Hasher.update(InputFile);
233230
for (auto *A : Args) {
234231
if (A->getOption().matches(options::OPT_INPUT))
235232
continue;

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

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

4+
// This test requires relative paths for input files. Since the test may be
5+
// done out of source tree, create the local directory structure and copy the
6+
// input file from the source tree into that directory.
7+
// RUN: mkdir -p %t/Inputs/hip_multiple_inputs
8+
// RUN: cp %S/Inputs/hip_multiple_inputs/a.cu %t/Inputs/hip_multiple_inputs/a.cu
9+
// RUN: cd %t
10+
411
// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
512
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
6-
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
13+
// RUN: Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
714

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

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

@@ -16,11 +23,11 @@
1623

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

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

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

0 commit comments

Comments
 (0)