[cfe-commits] r163109 - in /cfe/trunk: lib/Driver/ test/Driver/ test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/ test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/bin/ test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/ test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c++/ test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c++/4.4.3/ test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/lib/ test/Driver/Inputs/basic_android_tree/lib/ test...
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Mon Sep 3 02:05:50 PDT 2012
Author: eugenis
Date: Mon Sep 3 04:05:50 2012
New Revision: 163109
URL: http://llvm.org/viewvc/llvm-project?rev=163109&view=rev
Log:
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.
Added:
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/bin/
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/bin/.keep
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c++/
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c++/4.4.3/
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c++/4.4.3/.keep
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/lib/
cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/lib/.keep
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbegin.o
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbeginS.o
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbeginT.o
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtend.o
cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtendS.o
cfe/trunk/test/Driver/Inputs/basic_android_tree/sysroot/
cfe/trunk/test/Driver/Inputs/basic_android_tree/sysroot/usr/
- copied from r162659, cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/
cfe/trunk/test/Driver/android-standalone.cpp
Removed:
cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/asan-ld.c
cfe/trunk/test/Driver/linux-ld.c
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=163109&r1=163108&r2=163109&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Sep 3 04:05:50 2012
@@ -2124,6 +2124,11 @@
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 @@
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() +
- GCCInstallation.getMultiarchSuffix()),
- DriverArgs, CC1Args);
+ 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))
+ break;
}
}
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/bin/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/bin/.keep?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c++/4.4.3/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/include/c%2B%2B/4.4.3/.keep?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/lib/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/arm-linux-androideabi/lib/.keep?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbegin.o?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbeginS.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbeginS.o?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbeginT.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtbeginT.o?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtend.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtend.o?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtendS.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/crtendS.o?rev=163109&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/android-standalone.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-standalone.cpp?rev=163109&view=auto
==============================================================================
--- cfe/trunk/test/Driver/android-standalone.cpp (added)
+++ cfe/trunk/test/Driver/android-standalone.cpp Mon Sep 3 04:05:50 2012
@@ -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"
Modified: cfe/trunk/test/Driver/asan-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/asan-ld.c?rev=163109&r1=163108&r2=163109&view=diff
==============================================================================
--- cfe/trunk/test/Driver/asan-ld.c (original)
+++ cfe/trunk/test/Driver/asan-ld.c Mon Sep 3 04:05:50 2012
@@ -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)?}}"
Modified: cfe/trunk/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=163109&r1=163108&r2=163109&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Mon Sep 3 04:05:50 2012
@@ -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:[^"]+]]"
More information about the cfe-commits
mailing list