[cfe-dev] A bit of help with Clang C++ header search paths

Louis Dionne via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 22 13:35:17 PDT 2019

It looks like I just answered my question with this comment found in CC1:

void InitHeaderSearch::AddDefaultIncludePaths(...) {
  // NB: This code path is going away. All of the logic is moving into the
  // driver which has the information necessary to do target-specific
  // selections of default include paths. Each target which moves there will be
  // exempted from this logic here until we can delete the entire pile of code.

So it looks like this only happens on a few platforms (including Darwin), and this is just technical debt we need to get rid of. That makes sense to me and I'll try to take a stab at it.


> On Apr 22, 2019, at 16:21, Louis Dionne via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> Hi,
> Here's my understanding of how include paths for the C++ Standard Library work in Clang (this assumes -stdlib=libc++):
> 1. Based on the platform, the driver looks at various things like the installation path for Clang and passes `-internal-isystem <some-path>/c++/v1` to CC1.
> 2. The driver also passes -isysroot to CC1 if its own command-line contained -isysroot.
> 3. CC1 adds the path passed in -internal-isystem as the first search path in the search list.
> 4. CC1 looks at -isysroot and adds `<SYSROOT>/usr/include/c++/v1` to the header search paths (after whatever was specified in `-internal-isystem`). If no -isysroot was specified, `/` is used (and so `/usr/include/c++/v1` is added).
> 5. Any path that doesn't exist is removed from the list of search paths.
> Is this accurate? If so, I'm wondering why CC1 adds `<SYSROOT>/usr/include/c++/v1` to the search paths in (4) -- it seems like it should rely solely on the `-internal-isystem` path passed to it by the driver? Why isn't that the case?
> Thanks,
> Louis
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190422/a8687139/attachment.html>

More information about the cfe-dev mailing list