Repository navigation
release/22.x: [libclc] mark __clc_flush_denormal_if_not_supported as static inline - #207264
karolherbst wants to merge 1 commit into
Conversation
The compiled SPIR-V libclc binaries ended up with an empty definition for __clc_flush_denormal_if_not_supported. b8a5888 ("[libclc] Fix memory fence scope mapping for OpenCL (llvm#170542)") also added the static keyword probably due to the same issue. Fixes: 7f36611 ("[libclc] Remove __attribute__((always_inline)) (llvm#158791)")
|
Can we please get this fixed? Users start running into the issue of |
|
@wenju-he Have you seen this? |
zhangweize9-cyber
left a comment
There was a problem hiding this comment.
LGTM. The addition of static correctly addresses the potential symbol collision issue in Header-only scenarios. Good catch.
yeah, this is only an issue on the 22 release branch. Sadly I didn't catch that issue earlier (and I should probably start testing with newer releases more aggressively). But I also wasn't aware how short lived releases branches are as I just realized that normally no more releases are planned, is that right? |
I'm not familiar with llvm release cadence. 22.x branch is probably not frozen yet because 23 is not released yet. So critical bug fix should be ok to land in 22.x branch. |
Yeah, not sure if this is critical enough to make yet another release, but not my call to make. But I've seen other PRs against 22.x that were closed already, because of "we don't do another 22.x release". But it does break certain builtins like It also feels like the bug is actually something else, because it also looks like a codegen or tooling issue, though this PR is rather trivial and does fix the issue. Like in the SPIR-V (without this PR) I'm seeing this: And then multiple calls to it across the entire libclc: And I'd have expected that this would already break at linking time or something. Or I guess those are just normal C rules, because no translation unit actually instantiated the definition of |
Ok, then it might be difficult to land this to 22.x
This PR is the correct root-cause fix. Without static, _CLC_INLINE (inline) function in header is problematic in C: when function is not inlined in a TU, compiler assumes it will be provided by another file (which won't happen) and generates declaration for __clc_flush_denormal_if_not_supported in that TU. |
|
I guess I can really assume this isn't going to get merged? It's unfortunate because this now requires every distribution to patch their libclc packaging to get this working. So I'm kinda interested what's the best course of action for this is, because it feels weird that bugs preventing applications from running (in this case compilation of kernels would fail due to missing functions implementations) are fine to have. Is it common to require distribution to fix those kind of LLVM issues in their packaging? Is there a way to notify them? Should we just vendor libclc in mesa and deal with backporting on our own and ask distributions to simply use our vendored version? What's LLVM's position on this from a project perspective? If you prefer distributions to not ship libclc and that we should just ship it as a vendored version inside mesa, that's fine by us. Just wondering what the expectations here are? And to be fair, this is just outfall from not catching the bug in time, but now distributions just started to ship with libclc-22 and it's kinda broken now... |
|
Yes, this will not be merged, because the LLVM 22 release cycle has closed and there will be no further releases. This is not a value judgement on the importance of this issue, just a consequence of the release cycle. For issues found after the upstream release goes EOL, backporting at the distro level is indeed the right thing to do. In Fedora we usually accumulate a handful of additional backports after upstream EOL (for LLVM in general -- I can't recall an instance of us having to backport a libclc patch.) We probably should consider slightly extending the release cycle, to better bridge the gap between two releases. I believe the last time this happened was in https://discourse.llvm.org/t/rfc-distribute-patch-releases-over-lifecycle-of-an-llvm-version/80955, which extended the maintenance window by 6 weeks. |
Yeah.. atm I'm wondering what solution to go with. I currently created a fork for libclc based on llvm 21, 22 and 23 (so distros can pick their base) which is upstream libclc + a hand full of patches to at least make sure the CL CTS doesn't trigger issues caused by something inside libclc. I can say "yeah use those patches", but then I don't know if it could break things for other users, so I can only say "it's safe to use those patches with mesa". But maybe distributions would be fine with this, because I'm not sure there are any current users of the libclc-spirv packages and mesa could just use its own patched version for the time being? There are a few issues with the 23 version, but we have still time to fix it all up, if we manage in time. |
I was under the impression that C just requires an "anchor" definition in a source file, as explained in https://en.cppreference.com/c/language/inline:
The example illustrates how this is done:
Wouldn't it be possible to provide such an anchor definition in libclc? The problem with |
Yeah maybe, but 1. this issue doesn't exist on 23 and 2. on GPUs you are generally more aggressive with inlining anyway and 3. the function in question is rather small. I'm more concerned about the actual implementation because on most GPUs you can implement this function in 0 instructions (or if you are unlucky 1), but the current impl requires pattern matching in the compiler to actually optimize this. |
The compiled SPIR-V libclc binaries ended up with an empty definition for __clc_flush_denormal_if_not_supported.
b8a5888 ("[libclc] Fix memory fence scope mapping for OpenCL (#170542)") also added the static keyword probably due to the same issue.
Fixes: 7f36611 ("[libclc] Remove attribute((always_inline)) (#158791)")