Author: fineg74
Date: 2026-02-17T14:48:13Z
New Revision: db547e8846c9830f6843d41c310f8f707a470914

URL: 
https://github.com/llvm/llvm-project/commit/db547e8846c9830f6843d41c310f8f707a470914
DIFF: 
https://github.com/llvm/llvm-project/commit/db547e8846c9830f6843d41c310f8f707a470914.diff

LOG: [Clang][OpenMP][Driver] Make linker to link Device RTL  when built for 
SPIRV (#180066)

This is to make linker to link ompdevice library when building for
OpenMP using SPIRV

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/openmp-offload-gpu.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c16aa33f29ebb..1421c3b3b1ea4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9304,7 +9304,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
 
       // If this is OpenMP the device linker will need `-lompdevice`.
       if (Kind == Action::OFK_OpenMP && !Args.hasArg(OPT_no_offloadlib) &&
-          (TC->getTriple().isAMDGPU() || TC->getTriple().isNVPTX()))
+          TC->getTriple().isGPU())
         LinkerArgs.emplace_back("-lompdevice");
 
       // Forward all of these to the appropriate toolchain.

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index fb1bc9ffdbbd4..f12e79868fca2 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -410,3 +410,20 @@
 // RUN:   | FileCheck --check-prefix=SHOULD-EXTRACT %s
 //
 // SHOULD-EXTRACT: clang-linker-wrapper{{.*}}"--should-extract=gfx906"
+
+//
+// Check ompdevice is linked.
+//
+// RUN:   %clang -###  -fopenmp -fopenmp-targets=nvptx64 --offload-arch=sm_52 \
+// RUN:     --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
+// RUN:     
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc 
%s 2>&1 \
+// RUN:   | FileCheck --check-prefix=OMPDEVICE %s
+//
+// RUN:   %clang -###  -fopenmp -fopenmp-targets=amdgcn --offload-arch=gfx908 \
+// RUN:     --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=OMPDEVICE %s
+//
+// RUN:   %clang -###  -fopenmp -fopenmp-targets=spirv64 \
+// RUN:     
--libomptarget-spirv-bc-path=%S/Inputs/spirv-openmp/lib/libomptarget-spirv.bc 
%s 2>&1 \
+// RUN:   | FileCheck --check-prefix=OMPDEVICE %s
+// OMPDEVICE: clang-linker-wrapper{{.*}}--device-linker{{.*}}-lompdevice


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to