зеркало из https://github.com/microsoft/clang-1.git
Android standalone toolchain support.
This change adds detection of C++ headers and libraries paths when building with the standalone toolchain from Android NDK. They are in a slightly unusual place. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163109 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
7065c52fc5
Коммит
1d01afe4d5
|
@ -2124,6 +2124,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|||
addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
|
||||
addPathIfExists(LibPath + "/../" + Multilib, Paths);
|
||||
}
|
||||
// On Android, libraries in the parent prefix of the GCC installation are
|
||||
// preferred to the ones under sysroot.
|
||||
if (IsAndroid) {
|
||||
addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib", Paths);
|
||||
}
|
||||
}
|
||||
addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
|
||||
addPathIfExists(SysRoot + "/lib/../" + Multilib, Paths);
|
||||
|
@ -2342,16 +2347,22 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|||
StringRef LibDir = GCCInstallation.getParentLibPath();
|
||||
StringRef InstallDir = GCCInstallation.getInstallPath();
|
||||
StringRef Version = GCCInstallation.getVersion().Text;
|
||||
if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version,
|
||||
(GCCInstallation.getTriple().str() +
|
||||
GCCInstallation.getMultiarchSuffix()),
|
||||
DriverArgs, CC1Args)) {
|
||||
StringRef TripleStr = GCCInstallation.getTriple().str();
|
||||
|
||||
const std::string IncludePathCandidates[] = {
|
||||
LibDir.str() + "/../include/c++/" + Version.str(),
|
||||
// Gentoo is weird and places its headers inside the GCC install, so if the
|
||||
// first attempt to find the headers fails, try this pattern.
|
||||
addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
|
||||
(GCCInstallation.getTriple().str() +
|
||||
InstallDir.str() + "/include/g++-v4",
|
||||
// Android standalone toolchain has C++ headers in yet another place.
|
||||
LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.str(),
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < llvm::array_lengthof(IncludePathCandidates); ++i) {
|
||||
if (addLibStdCXXIncludePaths(IncludePathCandidates[i], (TripleStr +
|
||||
GCCInstallation.getMultiarchSuffix()),
|
||||
DriverArgs, CC1Args);
|
||||
DriverArgs, CC1Args))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// Test header and library paths when Clang is used with Android standalone
|
||||
// toolchain.
|
||||
//
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-androideabi \
|
||||
// RUN: -B%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck %s
|
||||
// CHECK: clang" "-cc1"
|
||||
// CHECK: "-internal-isystem" "{{.*}}/arm-linux-androideabi/include/c++/4.4.3"
|
||||
// CHECK: "-internal-isystem" "{{.*}}/arm-linux-androideabi/include/c++/4.4.3/arm-linux-androideabi"
|
||||
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
|
||||
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
|
||||
// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
|
||||
// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.4.3"
|
||||
// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib"
|
||||
// CHECK: "-L{{.*}}/sysroot/usr/lib"
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-androideabi -faddress-sanitizer \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
|
||||
// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ANDROID-NOT: "-lc"
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-androideabi -faddress-sanitizer \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: -shared \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SHARED %s
|
||||
// CHECK-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}"
|
||||
|
|
|
@ -365,11 +365,11 @@
|
|||
// Test linker invocation on Android.
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-androideabi \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-android \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
|
||||
// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
|
||||
// CHECK-ANDROID: "{{.*}}/crtbegin_dynamic.o"
|
||||
|
@ -380,12 +380,12 @@
|
|||
// CHECK-ANDROID: "{{.*}}/crtend_android.o"
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-androideabi \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: -shared \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-android \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: -shared \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s
|
||||
// CHECK-ANDROID-SO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
|
||||
|
@ -397,12 +397,12 @@
|
|||
// CHECK-ANDROID-SO: "{{.*}}/crtend_so.o"
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-androideabi \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: -static \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target arm-linux-android \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: -static \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
|
||||
// CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
|
||||
|
|
Загрузка…
Ссылка в новой задаче