[PATCH] D137470: [Offloading] Initial support for registering offloading entries on COFF targets

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 04:30:07 PST 2022


mstorsjo added a comment.

In D137470#3928870 <https://reviews.llvm.org/D137470#3928870>, @jhuber6 wrote:

> In D137470#3928828 <https://reviews.llvm.org/D137470#3928828>, @mstorsjo wrote:
>
>> Sorry, I'm not quite up to speed with exactly what is being done linker-wise here - can you give a more detailed overview? Keep in mind that there's two separate interfaces to lld for COFF; when used in mingw mode, it invokes the `ld.lld` frontend, but with a `-m` option which directs lld to the mingw frontend, which parses `ld.lld` style options and rewrites them to `lld-link` style options and invokes that interface. And when Clang is operating in msvc/clang-cl mode, `lld-link` is invoked (or called directly by the build system).
>
> Sure, there's a bit of documentation <https://clang.llvm.org/docs/OffloadingDesign.html> for what's going on here, but I may need to update it a bit.
>
> Basically, for offloading languages (CUDA, HIP, OpenMP, etc) we compile the source code twice, once for the host and once for the target device. We embed the device relocatable object inside the host so we follow a standard compilation pipeline. This `linker-wrapper` then fishes those relocatable objects out and performs the device-linking phase. The linked output is then put into a global along with some runtime calls to register the image and kernels. That new file gets passed to the wrapped linker job and we get a final executable.
>
> My concern is that the linker wrapper keys off of certain arguments to the linker to do its job since it's invoked something like `clang-linker-wrapper <linker-args>`. I understand these are fundamentally different for `lld-link` so I was wondering if this approach in general would work there.

Right, yes, `lld-link` uses different arguments than `ld.lld`. (Also note that for mingw targets, the regular `ld.lld` interface is used on Windows too, while `link.exe` or `lld-link` is used for msvc targets.)

Anyway, I don't have much other comments on this - other than what I commented before, this seems mostly reasonable, but I'm not familiar enough with the whole OpenMP pipeline to give any authoritative review really. Feel free to ask specifically about other details relating to PE/COFF though!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137470



More information about the llvm-commits mailing list