[PATCH] D95055: [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 Jan 20 09:18:29 PST 2021


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

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.

This is a cherry-pick of commit a3a24316087d0e1b4db0b8fee19cdee8b7968032 <https://reviews.llvm.org/rGa3a24316087d0e1b4db0b8fee19cdee8b7968032>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95055

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: D95055.317899.patch
Type: text/x-patch
Size: 12952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210120/03f18d3c/attachment.bin>


More information about the cfe-commits mailing list