Commit Graph

7 Commits

Author SHA1 Message Date
Louis Dionne a3a2431608 [clang] Don't look into <sysroot> for C++ headers if they are found alongside the toolchain
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.

Differential Revision: https://reviews.llvm.org/D89001
2020-10-09 12:41:41 -04:00
Hubert Tong 15f0f824b3 [tests][Driver] Set `--sysroot=""` to allow `DEFAULT_SYSROOT` build
Summary:
If `DEFAULT_SYSROOT` is configured to some path, some tests would fail.
This patch overrides `sysroot` to be the empty string in the style of
D66834 so that the tests will pass even when the build is configured
with a `DEFAULT_SYSROOT`.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D79694
2020-05-15 17:34:00 -04:00
Louis Dionne 361ba3ad1f [Driver][Darwin] Improve tests for -nostdinc & friends
The tests were slightly underspecifying the current behavior of Clang.
2020-02-04 19:31:53 -05:00
James Y Knight b2ece169ed Add back --sysroot support for darwin header search.
Before e97b5f5cf3 ([clang][Darwin] Refactor header search path logic
into the driver), both --sysroot and -isysroot worked to specify where
to look for system and C++ headers on Darwin. However, that change
caused clang to start ignoring --sysroot.

This fixes the regression, and adds tests.

(I also note that on all other platforms, clang seems to almost
completely ignore -isysroot, but that's another issue...)

Differential Revision: https://reviews.llvm.org/D62268

llvm-svn: 361429
2019-05-22 20:39:51 +00:00
Russell Gallop 529141e4ad Mark tests from r361278 as unsupported on Windows.
llvm-svn: 361374
2019-05-22 12:07:52 +00:00
Richard Smith 1f4548b507 Fix test failures after r361278 on non-Darwin platforms and when
CLANG_DEFAULT_STDLIB is defined to libstdc++.

llvm-svn: 361301
2019-05-21 20:10:52 +00:00
Louis Dionne e97b5f5cf3 [clang][Darwin] Refactor header search path logic into the driver
Summary:
This commit moves the logic for determining system, resource and C++
header search paths from CC1 to the driver. This refactor has already
been made for several platforms, but Darwin had been left behind.

This refactor tries to implement the previous search path logic with
perfect accuracy. In particular, the order of all include paths inside
CC1 and all paths that were skipped because nonexistent are conserved
after the refactor. This change was also tested against a code base
of significant size and revealed no problems.

Reviewers: jfb, arphaman

Subscribers: nemanjai, javed.absar, kbarton, christof, jkorous, dexonsmith, jsji, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61963

llvm-svn: 361278
2019-05-21 17:48:04 +00:00