summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains/Linux.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-12-06 15:54:47 -0800
committerPeter Collingbourne <peter@pcc.me.uk>2019-12-09 10:08:02 -0800
commitbab9849963eb9b9f1fa03900e8c48a7c7d6fc305 (patch)
tree222869314e28f815136956e65100136d7644765e /clang/lib/Driver/ToolChains/Linux.cpp
parentbe05633e28949139093278d5ce57a194756bfb83 (diff)
downloadbcm5719-llvm-bab9849963eb9b9f1fa03900e8c48a7c7d6fc305.tar.gz
bcm5719-llvm-bab9849963eb9b9f1fa03900e8c48a7c7d6fc305.zip
Reland 198fbcb8, "Driver: Don't look for libc++ headers in the install directory on Android.", which was reverted in b3249027.
Fixed the test case to set --sysroot, which lets it succeed in the case where a directory named "/usr/include/c++/v1" or "/usr/local/include/c++/v1" exists. Original commit message: > The NDK uses a separate set of libc++ headers in the sysroot. Any headers > in the installation directory are not going to work on Android, not least > because they use a different name for the inline namespace (std::__1 instead > of std::__ndk1). > > This effectively makes it impossible to produce a single toolchain that is > capable of targeting both Android and another platform that expects libc++ > headers to be installed in the installation directory, such as Mac. > > In order to allow this scenario to work, stop looking for headers in the > install directory on Android. Differential Revision: https://reviews.llvm.org/D71154
Diffstat (limited to 'clang/lib/Driver/ToolChains/Linux.cpp')
-rw-r--r--clang/lib/Driver/ToolChains/Linux.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 736a2d435ca..adacd705d83 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -888,20 +888,25 @@ static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs,
void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
const std::string& SysRoot = computeSysRoot();
- const std::string LibCXXIncludePathCandidates[] = {
- DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
- // If this is a development, non-installed, clang, libcxx will
- // not be found at ../include/c++ but it likely to be found at
- // one of the following two locations:
- DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
- DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
- for (const auto &IncludePath : LibCXXIncludePathCandidates) {
+ auto AddIncludePath = [&](std::string Path) {
+ std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
if (IncludePath.empty() || !getVFS().exists(IncludePath))
- continue;
- // Use the first candidate that exists.
+ return false;
addSystemInclude(DriverArgs, CC1Args, IncludePath);
+ return true;
+ };
+ // Android never uses the libc++ headers installed alongside the toolchain,
+ // which are generally incompatible with the NDK libraries anyway.
+ if (!getTriple().isAndroid())
+ if (AddIncludePath(getDriver().Dir + "/../include/c++"))
+ return;
+ // If this is a development, non-installed, clang, libcxx will
+ // not be found at ../include/c++ but it likely to be found at
+ // one of the following two locations:
+ if (AddIncludePath(SysRoot + "/usr/local/include/c++"))
+ return;
+ if (AddIncludePath(SysRoot + "/usr/include/c++"))
return;
- }
}
void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
OpenPOWER on IntegriCloud