Skip to content

Commit b324902

Browse files
committed
Revert "Driver: Don't look for libc++ headers in the install directory on Android."
This reverts commit 198fbcb. This breaks Fedora 31.
1 parent 68f464a commit b324902

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -888,25 +888,20 @@ static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs,
888888
void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
889889
llvm::opt::ArgStringList &CC1Args) const {
890890
const std::string& SysRoot = computeSysRoot();
891-
auto AddIncludePath = [&](std::string Path) {
892-
std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
891+
const std::string LibCXXIncludePathCandidates[] = {
892+
DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
893+
// If this is a development, non-installed, clang, libcxx will
894+
// not be found at ../include/c++ but it likely to be found at
895+
// one of the following two locations:
896+
DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
897+
DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
898+
for (const auto &IncludePath : LibCXXIncludePathCandidates) {
893899
if (IncludePath.empty() || !getVFS().exists(IncludePath))
894-
return false;
900+
continue;
901+
// Use the first candidate that exists.
895902
addSystemInclude(DriverArgs, CC1Args, IncludePath);
896-
return true;
897-
};
898-
// Android never uses the libc++ headers installed alongside the toolchain,
899-
// which are generally incompatible with the NDK libraries anyway.
900-
if (!getTriple().isAndroid())
901-
if (AddIncludePath(getDriver().Dir + "/../include/c++"))
902-
return;
903-
// If this is a development, non-installed, clang, libcxx will
904-
// not be found at ../include/c++ but it likely to be found at
905-
// one of the following two locations:
906-
if (AddIncludePath(SysRoot + "/usr/local/include/c++"))
907-
return;
908-
if (AddIncludePath(SysRoot + "/usr/include/c++"))
909903
return;
904+
}
910905
}
911906

912907
void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,

clang/test/Driver/android-no-installed-libcxx.cpp

Lines changed: 0 additions & 8 deletions
This file was deleted.

clang/test/Driver/stdlibxx-isystem.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// By default, we should search for libc++ next to the driver.
77
// RUN: mkdir -p %t/bin
88
// RUN: mkdir -p %t/include/c++/v1
9-
// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
9+
// RUN: %clang -target aarch64-linux-android -ccc-install-dir %t/bin \
1010
// RUN: -stdlib=libc++ -fsyntax-only %s -### 2>&1 | \
1111
// RUN: FileCheck -check-prefix=LIBCXX %s
1212
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
@@ -16,7 +16,7 @@
1616
// LIBCXX: "-internal-isystem" "[[INSTALLDIR]]/../include/c++/v1"
1717

1818
// Passing -stdlib++-isystem should suppress the default search.
19-
// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
19+
// RUN: %clang -target aarch64-linux-android -ccc-install-dir %t/bin \
2020
// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -stdlib=libc++ \
2121
// RUN: -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NODEFAULT %s
2222
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
@@ -26,7 +26,7 @@
2626
// NODEFAULT-NOT: "-internal-isystem" "[[INSTALLDIR]]/../include/c++/v1"
2727

2828
// And we should add it as an -internal-isystem.
29-
// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
29+
// RUN: %clang -target aarch64-linux-android -ccc-install-dir %t/bin \
3030
// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -stdlib=libc++ \
3131
// RUN: -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=INCPATH %s
3232
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
@@ -35,7 +35,7 @@
3535
// INCPATH: "-internal-isystem" "/tmp/foo" "-internal-isystem" "/tmp/bar"
3636

3737
// We shouldn't pass the -stdlib++-isystem to cc1.
38-
// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
38+
// RUN: %clang -target aarch64-linux-android -ccc-install-dir %t/bin \
3939
// RUN: -stdlib++-isystem /tmp -stdlib=libc++ -fsyntax-only %s -### 2>&1 | \
4040
// RUN: FileCheck -check-prefix=NOCC1 %s
4141
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
@@ -44,7 +44,7 @@
4444
// NOCC1-NOT: "-stdlib++-isystem" "/tmp"
4545

4646
// It should respect -nostdinc++.
47-
// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
47+
// RUN: %clang -target aarch64-linux-android -ccc-install-dir %t/bin \
4848
// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdinc++ \
4949
// RUN: -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NOSTDINCXX %s
5050
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \

0 commit comments

Comments
 (0)