-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[Clang] Only link C device libraries by default for OpenMP #151239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/151239.diff 1 Files Affected:
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) {
|
These don't provide any of the standard entry point names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test
I can't think of an easy way to test this since it looks at the compiler build tree. |
It does in practice, though I haven't bothered to investigate why. |
Not sure how this could depend on the build tree, but we have various tests targeting fake sysroots in clang/test/Driver/Inputs |
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.