[clang] [Clang] Only C link device libraries by default for OpenMP (PR #151239)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 29 14:47:29 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-clang
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
Summary:
We link these implicitly for OpenMP because it's the canonical
implementation of those C language features. This was inhereted by HIP
and ended up with these resolving functions. There are some useful
functions in here, but this can be problematic as it could potentially
override functions intended to be provided by the ROCm device libraries.
Additionally the HIP runtime does not currently provide the handling for
the RPC server required to run the host resources so those just segfault.
---
Full diff: https://github.com/llvm/llvm-project/pull/151239.diff
1 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-2)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 9d882dbfd0c65..6e1d4aa8bc053 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9232,8 +9232,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_nogpulibc)) {
forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) {
// The device C library is only available for NVPTX and AMDGPU targets
- // currently.
- if (!TC.getTriple().isNVPTX() && !TC.getTriple().isAMDGPU())
+ // and we only link it by default for OpenMP currently.
+ if (!TC.getTriple().isNVPTX() && !TC.getTriple().isAMDGPU() ||
+ !JA.isHostOffloading(Action::OFK_OpenMP))
return;
bool HasLibC = TC.getStdlibIncludePath().has_value();
if (HasLibC) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/151239
More information about the cfe-commits
mailing list