[clang] [Clang][OpenMP][Driver] Make linker to link Device RTL when built for SPIRV (PR #180066)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 13 15:04:04 PST 2026
https://github.com/fineg74 updated https://github.com/llvm/llvm-project/pull/180066
>From f4498e94beeb8ace874bb931ff7f6517e4ef6940 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Thu, 5 Feb 2026 15:19:56 -0800
Subject: [PATCH 1/2] Make linker to link Device RTL when built for SPIRV
---
clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 5575b644c6814..a455ad56d4f72 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9283,7 +9283,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.
>From 397cba6fda3ee6c95d9fabcb614d0483b16fea53 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Fri, 13 Feb 2026 15:03:54 -0800
Subject: [PATCH 2/2] Add a test
---
clang/test/Driver/openmp-offload-gpu.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
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
More information about the cfe-commits
mailing list