[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 12 12:54:09 PDT 2022


yaxunl added a comment.

In D123441#3446478 <https://reviews.llvm.org/D123441#3446478>, @tra wrote:

>> This approach will only link in kernels and device variables used by host code
>
> In the absence of the explicit reference info from the host side, GPU-side linker  must link all objects with symbols that **may** be used by the host.
> E.g if we have a library with three objects, each has one kernel (and thus potentially used by the host), but the main TU only refers to a kernel from one of them, GPU-side linker would still have to link in all three objects from the library, as any of them may have been referenced by the host.

You are talking about a use case that actually needs --whole-archive option. If the main TU does not reference some symbols in the archive but wants all symbols in the archive to be linked in, it is justifiable to use --whole-archive and HIP toolchain can support passing -Wl,--whole-archive specified in the command line to the device linking step.

However, in normal use cases, users only want to link in symbols referenced by the main TU. They do not need to link every symbol in the archive.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123441/new/

https://reviews.llvm.org/D123441



More information about the cfe-commits mailing list