[PATCH] D138862: [Clang] Do not set offload kind in a freestanding build

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 28 16:25:27 PST 2022


jhuber6 added a comment.

In D138862#3955502 <https://reviews.llvm.org/D138862#3955502>, @tra wrote:

> However, we probably  need some sort of safeguards warning users if they compile CUDA *kernels* or code w/ global variable in freestanding mode.

The behavior of `-ffreestanding` isn't well documented in the first place, so there could be some downsides to doing something like this internally. Although it is externally visible if you use `llvm-objdump --offloading` on the resulting object.

> Also considering that `-freestanding` mode will not be very useful if the user does compile something that does need runtime, perhaps we can turn things around and always mark the GPU object as generic unless we do know that it requires runtime support?
> This way you don't need `-freestanding` at all. Whether the resulting GPU object is generic would be determined by what we're compiling.

The difficulty here is that this is done at the driver level which can't see the source code. So we wouldn't have a good way to signal back that we actually needed the runtime after compiling it.

> Later, if/when we actually want users to provide their own runtime (as opposed to not tying the generated code to specific runtime if we don't need to), we can implement a fully functional freestanding mode. I suspect we may need it for a while yet.

We could potentially make the `None` kind still embed the linked image so users could write custom runtimes if they so desired.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138862



More information about the cfe-commits mailing list