[clang] [CUDA/HIP] fix propagate -cuid to a host-only compilation. (PR #111650)

Pankaj Dwivedi via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 9 02:14:44 PDT 2024


https://github.com/PankajDwivedi-25 created https://github.com/llvm/llvm-project/pull/111650

build failure is observed in the hip test after patch #107483, which complains about a linking error.

"/usr/bin/ld: /opt/rocm/share/hip/samples/2_Cookbook/16_assembly_to_executable/build/square_asm.out: hidden symbol `__hip_gpubin_handle_b21320dde8d193a' isn't defined
/usr/bin/ld: final link failed: bad value"


>From 7fab0002d9febf440545043d8782d7243a03f17b Mon Sep 17 00:00:00 2001
From: Pankajdwivedi-25 <pankajkumar.divedi at amd.com>
Date: Wed, 9 Oct 2024 14:34:17 +0530
Subject: [PATCH] [HIP] this is pre-commit might not be the solution fixes the
 linking issue

---
 clang/lib/Driver/Driver.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a5d43bdac23735..d6cdc40b0a292e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3073,7 +3073,6 @@ class OffloadingActionBuilder final {
             CUID = llvm::utohexstr(Hash.low(), /*LowerCase=*/true);
           }
         }
-        IA->setId(CUID);
 
         if (CompileHostOnly)
           return ABRT_Success;
@@ -3081,6 +3080,8 @@ class OffloadingActionBuilder final {
         // Replicate inputs for each GPU architecture.
         auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE
                                                  : types::TY_CUDA_DEVICE;
+        IA->setId(CUID);
+        
         for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
           CudaDeviceActions.push_back(
               C.MakeAction<InputAction>(IA->getInputArg(), Ty, IA->getId()));



More information about the cfe-commits mailing list