[clang] Reland "[HIP] Use original file path for CUID" (#108771) (PR #111885)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 22 10:54:21 PST 2025


https://github.com/yxsamliu updated https://github.com/llvm/llvm-project/pull/111885

>From 6a3a200019f7d0973f35a83d735a2f517d636e3e Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" <yaxun.liu at amd.com>
Date: Wed, 25 Sep 2024 14:31:54 -0400
Subject: [PATCH] Reland "[HIP] Use original file path for CUID" (#108771)

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.
---
 clang/lib/Driver/Driver.cpp         |  5 +----
 clang/test/Driver/hip-cuid-hash.hip | 10 ++++++----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 87855fdb799710..4db809a8937072 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -226,10 +226,7 @@ std::string CUIDOptions::getCUID(StringRef InputFile,
     else if (UseCUID == Kind::Hash) {
       llvm::MD5 Hasher;
       llvm::MD5::MD5Result Hash;
-      SmallString<256> RealPath;
-      llvm::sys::fs::real_path(InputFile, RealPath,
-                               /*expand_tilde=*/true);
-      Hasher.update(RealPath);
+      Hasher.update(InputFile);
       for (auto *A : Args) {
         if (A->getOption().matches(options::OPT_INPUT))
           continue;
diff --git a/clang/test/Driver/hip-cuid-hash.hip b/clang/test/Driver/hip-cuid-hash.hip
index 103a1cbf26d50a..28efd6197b2303 100644
--- a/clang/test/Driver/hip-cuid-hash.hip
+++ b/clang/test/Driver/hip-cuid-hash.hip
@@ -1,13 +1,15 @@
 // Check CUID generated by hash.
 // The same CUID is generated for the same file with the same options.
 
+// RUN: cd %S
+
 // RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
 // RUN:   --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
-// RUN:   %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
+// RUN:   Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
 
 // RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
 // RUN:   --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
-// RUN:   %S/Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
+// RUN:   Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
 
 // RUN: FileCheck %s -check-prefixes=SAME -input-file %t.out
 
@@ -16,11 +18,11 @@
 
 // RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu -DX=1 --no-offload-new-driver \
 // RUN:   --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
-// RUN:   %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
+// RUN:   Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
 
 // RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu -DX=2 --no-offload-new-driver \
 // RUN:   --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
-// RUN:   %S/Inputs/../Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
+// RUN:   Inputs/../Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
 
 // RUN: FileCheck %s -check-prefixes=DIFF -input-file %t.out
 



More information about the cfe-commits mailing list