[PATCH] D89001: [clang] Don't look into <sysroot> for C++ headers if they are found alongside the toolchain

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 12:29:08 PDT 2020


ldionne created this revision.
ldionne added reviewers: arphaman, dexonsmith.
Herald added subscribers: cfe-commits, jkorous.
Herald added a project: clang.
ldionne requested review of this revision.

Currently, Clang looks for libc++ headers alongside the installation
directory of Clang, and it also adds a search path for headers in the
-isysroot. This is problematic if headers are found in both the toolchain
and in the sysroot, since #include_next will end up finding the libc++
headers in the sysroot instead of the intended system headers.

This patch changes the logic such that if the toolchain contains libc++
headers, no C++ header paths are added in the sysroot. However, if the
toolchain does *not* contain libc++ headers, the sysroot is searched as
usual.

This should not be a breaking change, since any code that previously
relied on some libc++ headers being found in the sysroot suffered from
the #include_next issue described above, which renders any libc++ header
basically useless.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89001

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/lib/.keep
  clang/test/Driver/darwin-header-search-libcxx.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89001.296771.patch
Type: text/x-patch
Size: 12892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201007/ec677cb6/attachment-0001.bin>


More information about the cfe-commits mailing list