[Clang] Implicitly include LLVM libc headers for the GPU
authorJoseph Huber <jhuber6@vols.utk.edu>
Mon, 27 Mar 2023 15:01:12 +0000 (10:01 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Mon, 3 Apr 2023 17:57:21 +0000 (12:57 -0500)
commitf263bd8f7d4c82af9672803e6d8d57f25c929d00
tree0352cb8967f4542340ee048c6236bfdbd4169327
parent0a8d1ee739175b2039fc1656c88681d1a4326a0f
[Clang] Implicitly include LLVM libc headers for the GPU

There is currently work to support basic `libc` functionality on the
GPU. Some basic information about the projects can be found at
https://libc.llvm.org/gpu_mode.html. Typically, including the system
headers on the GPU will result in an error. For this reason the LLVM
`libc` project will generate its own headers that can be used with the
GPU.

The problem is that these headers will use the same name as the system headers.
For that reason, D146970 places it in the `llvm-libc` subfolder. In order to
still pick these files up, this patch adds changes in clang to default to
searching this directory when targeting the GPU. This lets offloading languages
such as OpenMP use the system `string.h` when compiling for the host and then
the LLVM libc `string.h` when targeting the GPU.

Depends on D146970

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D146973
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/gpu-libc-headers.c [new file with mode: 0644]