[libc-commits] [PATCH] D153897: [libc][hdr-gen] Add special offloading handling for the GPU target

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jun 27 10:35:37 PDT 2023


jhuber6 added a comment.

The extent with which we need to work against system headers that are hostile to being included is unfortunate, but I firmly believe this is the only workable solution for exporting these interfaces to the expected users. The only alternative and sound solution is to provide a complete `libc` for the host system and GPU and use a unified header that works on both flawlessly. This is a nice goal, but is most likely many, many years away from being possible and would require the user to change their system configuration. This at least has the effect of generating headers that can then replace the ad-hoc ones that exist in `clang` and can be used as a base for further development.

There are a few ugly points that have not been addressed by this patch, namely

1. If the system header is not compatible with the implemented ABI:  E.g. if `div_t` is not defined in the order `quot; rem`. For these cases we can statically assert to at least prevent miscompilations, but I think this will be rare
2. System definitions we will need to manually override on the GPU: Something like `errno` is a macro that's defined by the system headers. If we with to provide this on the GPU we will need a special section to `undef` it and reset it to ours only for the GPU compilation.
3. A handful of entrypoints use a type that is not C-standard. E.g. the `atexit` function uses `__atexit_handler_t` which is defined internally. We will need to replace these, or define it as a workaround for the GPU.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153897



More information about the libc-commits mailing list