[clang] [llvm] [LinkerWrapper] Support relocatable linking for offloading (PR #80066)

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 31 11:18:33 PST 2024


Artem-B wrote:

> I'm assuming you're talking about GPU-side constructors? I don't think the CUDA runtime supports those, but OpenMP runs them when the image is loaded, so it would handle both independantly.

Yes. I'm thinking of the expectations from a C++ user standpoint, and this is one of the areas where there will be observable differences. First, because there will be subsets of the code that are no longer part of the main GPU-side executable. Second, the side effects of the initializers will be different depending on whether we do link such subsets separately or not. E.g. the initializer call order will change. The global state changes in one subset will not be visible in the other. Weak symbol resolution will produce different results. Etc.

> The idea is that users already get C++-like behavior with the new driver and -fgpu-rdc generally

Yes. That will set the default expectations that things work just like in C++, which is a great thing. But introduction of partial subset linking will break some of those "just works" assumptions and it may be triggered by the parts of the build  outside of user's control (e.g. by a third-party library). 

Side note: we do need a good term for this kind of subset linking. "partial linking" already has established meaning and it's not a good fit here as we actually produce a fully linked GPU executable.

> we don't need to worry about people being confused so long as we document what it does.

We do need to document how it works. Documenting what does not work, or works differently is also important, IMO. 
We *do* need to worry about users and their expectations. 




https://github.com/llvm/llvm-project/pull/80066


More information about the cfe-commits mailing list