[PATCH] D146973: [Clang] Implicitly include LLVM libc headers for the GPU

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 3 11:18:49 PDT 2023


tra added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1196-1197
 
+  // If we are compiling for a GPU target we want to override the system headers
+  // with ones created by the 'libc' project if present.
+  if (!Args.hasArg(options::OPT_nostdinc) &&
----------------
jhuber6 wrote:
> tra wrote:
> > Please add a TODO with some details outlining what it's supposed to do, the issues we've discussed, and that this is intended to be a temporary solution (famous last words, I know).
> > 
> > 
> I'm not sure if we should consider this temporary, we simply need to ensure that the headers in this directory are compatible with the host environment somehow.
> we simply need to ensure that the headers in this directory are compatible with the host environment somehow.

The problem is that you probably do not have the *correct* host environment to be compatible with, yet. You do need to compile the host headers with the host-specific macros defined and that will make some of the code in them uncompileable for NVPTX (e.g due to inline asm or unavailable builtins). 

Nor do we have the long-term solution for the "compatible, somehow" part, as we're replacing part of the host headers, implementation of which we do not control. 

We can drop the 'temporary' part, but I think the story here is far from over, so a prominent TODO is needed.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146973



More information about the cfe-commits mailing list