[libclc] [libclc][NFC] Prioritize clang's built-in opencl-c-base.h over CPATH versions (PR #177754)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 25 17:00:44 PST 2026


wenju-he wrote:

It seems difficult to change resource directory to the first priority in clang. Changing current order may cause breakage. It requires at least two changes:
1. adding following code for OpenCL before https://github.com/llvm/llvm-project/blob/2c7cf896be28febcd2f9af1b0dfdb5dfc6b97583/clang/lib/Driver/ToolChains/Clang.cpp#L1122
```
SmallString<128> Dir(D.ResourceDir);
llvm::sys::path::append(Dir, "include");
CmdArgs.push_back("-I");
CmdArgs.push_back(Args.MakeArgString(Dir));`
```
2. disable following code for OpenCL: https://github.com/llvm/llvm-project/blob/2c7cf896be28febcd2f9af1b0dfdb5dfc6b97583/clang/lib/Lex/InitHeaderSearch.cpp#L185-L191

These two changes are basically what this PR does, but within libclc.

The first change may contradict with current AddClangSystemIncludeArgs implementation which includes resource dir via -internal-isystem, e.g. at https://github.com/llvm/llvm-project/blob/2c7cf896be28febcd2f9af1b0dfdb5dfc6b97583/clang/lib/Driver/ToolChains/Linux.cpp#L750-L758

Note libc also uses -nostdlibinc in https://github.com/llvm/llvm-project/pull/97461

https://github.com/llvm/llvm-project/pull/177754


More information about the cfe-commits mailing list