r329234 - [Driver] Include the Android multiarch includes.
Dan Albert via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 4 14:28:34 PDT 2018
Author: danalbert
Date: Wed Apr 4 14:28:34 2018
New Revision: 329234
URL: http://llvm.org/viewvc/llvm-project?rev=329234&view=rev
Log:
[Driver] Include the Android multiarch includes.
Summary:
Most Android headers live in a single directory, but a small handful
live in multiarch directories.
Reviewers: srhines
Reviewed By: srhines
Subscribers: javed.absar, cfe-commits
Differential Revision: https://reviews.llvm.org/D44995
Added:
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/include/c++/4.9/x86_64-linux-android/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/include/c++/4.9/x86_64-linux-android/.keep
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/crtbegin.o
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/crtend.o
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/include/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/include/.keep
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/aarch64-linux-android/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/aarch64-linux-android/.keep
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/arm-linux-androideabi/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/arm-linux-androideabi/.keep
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/i686-linux-android/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/i686-linux-android/.keep
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/x86_64-linux-android/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/x86_64-linux-android/.keep
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld.bfd
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld.gold
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/lib/
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/lib/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/android-ndk-standalone.cpp
Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=329234&r1=329233&r2=329234&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Wed Apr 4 14:28:34 2018
@@ -42,6 +42,7 @@ static std::string getMultiarchTriple(co
StringRef SysRoot) {
llvm::Triple::EnvironmentType TargetEnvironment =
TargetTriple.getEnvironment();
+ bool IsAndroid = TargetTriple.isAndroid();
// For most architectures, just use whatever we have rather than trying to be
// clever.
@@ -55,7 +56,9 @@ static std::string getMultiarchTriple(co
// regardless of what the actual target triple is.
case llvm::Triple::arm:
case llvm::Triple::thumb:
- if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
+ if (IsAndroid) {
+ return "arm-linux-androideabi";
+ } else if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf"))
return "arm-linux-gnueabihf";
} else {
@@ -74,16 +77,22 @@ static std::string getMultiarchTriple(co
}
break;
case llvm::Triple::x86:
+ if (IsAndroid)
+ return "i686-linux-android";
if (D.getVFS().exists(SysRoot + "/lib/i386-linux-gnu"))
return "i386-linux-gnu";
break;
case llvm::Triple::x86_64:
+ if (IsAndroid)
+ return "x86_64-linux-android";
// We don't want this for x32, otherwise it will match x86_64 libs
if (TargetEnvironment != llvm::Triple::GNUX32 &&
D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
return "x86_64-linux-gnu";
break;
case llvm::Triple::aarch64:
+ if (IsAndroid)
+ return "aarch64-linux-android";
if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
return "aarch64-linux-gnu";
break;
@@ -96,6 +105,8 @@ static std::string getMultiarchTriple(co
return "mips-linux-gnu";
break;
case llvm::Triple::mipsel:
+ if (IsAndroid)
+ return "mipsel-linux-android";
if (D.getVFS().exists(SysRoot + "/lib/mipsel-linux-gnu"))
return "mipsel-linux-gnu";
break;
@@ -106,6 +117,8 @@ static std::string getMultiarchTriple(co
return "mips64-linux-gnuabi64";
break;
case llvm::Triple::mips64el:
+ if (IsAndroid)
+ return "mips64el-linux-android";
if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu"))
return "mips64el-linux-gnu";
if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnuabi64"))
@@ -717,6 +730,14 @@ void Linux::AddClangSystemIncludeArgs(co
default:
break;
}
+
+ const std::string AndroidMultiarchIncludeDir =
+ std::string("/usr/include/") +
+ getMultiarchTriple(D, getTriple(), SysRoot);
+ const StringRef AndroidMultiarchIncludeDirs[] = {AndroidMultiarchIncludeDir};
+ if (getTriple().isAndroid())
+ MultiarchIncludeDirs = AndroidMultiarchIncludeDirs;
+
for (StringRef Dir : MultiarchIncludeDirs) {
if (D.getVFS().exists(SysRoot + Dir)) {
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir);
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/include/c++/4.9/x86_64-linux-android/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/include/c%2B%2B/4.9/x86_64-linux-android/.keep?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/crtbegin.o?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/crtend.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/crtend.o?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/include/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/lib/gcc/x86_64-linux-android/4.9/include/.keep?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/aarch64-linux-android/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/aarch64-linux-android/.keep?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/arm-linux-androideabi/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/arm-linux-androideabi/.keep?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/i686-linux-android/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/i686-linux-android/.keep?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/x86_64-linux-android/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/include/x86_64-linux-android/.keep?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld.bfd
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld.bfd?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld.gold
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/bin/ld.gold?rev=329234&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/lib/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/x86_64-linux-android/lib/.keep?rev=329234&view=auto
==============================================================================
(empty)
Modified: cfe/trunk/test/Driver/android-ndk-standalone.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-ndk-standalone.cpp?rev=329234&r1=329233&r2=329234&view=diff
==============================================================================
--- cfe/trunk/test/Driver/android-ndk-standalone.cpp (original)
+++ cfe/trunk/test/Driver/android-ndk-standalone.cpp Wed Apr 4 14:28:34 2018
@@ -19,6 +19,7 @@
// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
// CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
// CHECK: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -56,6 +57,7 @@
// CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
// CHECK-ARMV7: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
// CHECK-ARMV7: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
// CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK-ARMV7: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -115,6 +117,7 @@
// CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
// CHECK-THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
// CHECK-THUMB: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
// CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK-THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -154,6 +157,7 @@
// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
// CHECK-ARMV7THUMB: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
// CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK-ARMV7THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -203,6 +207,7 @@
// CHECK-AARCH64: "-internal-isystem" "{{.*}}/include/c++/4.9"
// CHECK-AARCH64: "-internal-isystem" "{{.*}}/include/c++/4.9/aarch64-linux-android"
// CHECK-AARCH64: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/aarch64-linux-android"
// CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK-AARCH64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -219,6 +224,7 @@
// CHECK-ARM64: "-internal-isystem" "{{.*}}/include/c++/4.9"
// CHECK-ARM64: "-internal-isystem" "{{.*}}/include/c++/4.9/aarch64-linux-android"
// CHECK-ARM64: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/aarch64-linux-android"
// CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK-ARM64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -321,9 +327,28 @@
// CHECK-I686: "-internal-isystem" "{{.*}}/include/c++/4.9"
// CHECK-I686: "-internal-isystem" "{{.*}}/include/c++/4.9/i686-linux-android"
// CHECK-I686: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-I686: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/i686-linux-android"
// CHECK-I686: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK-I686: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK-I686: "-L{{.*}}/lib/gcc/i686-linux-android/4.9"
// CHECK-I686: "-L{{.*}}/lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/lib"
// CHECK-I686: "-L{{.*}}/sysroot/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-linux-android \
+// RUN: -stdlib=libstdc++ \
+// RUN: -B%S/Inputs/basic_android_ndk_tree \
+// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
+// RUN: | FileCheck --check-prefix=CHECK-X86_64 %s
+// CHECK-X86_64: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-X86_64: "-internal-isystem" "{{.*}}/include/c++/4.9"
+// CHECK-X86_64: "-internal-isystem" "{{.*}}/include/c++/4.9/x86_64-linux-android"
+// CHECK-X86_64: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-X86_64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/x86_64-linux-android"
+// CHECK-X86_64: "-internal-externc-isystem" "{{.*}}/sysroot/include"
+// CHECK-X86_64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
+// CHECK-X86_64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-X86_64: "-L{{.*}}/lib/gcc/x86_64-linux-android/4.9"
+// CHECK-X86_64: "-L{{.*}}/lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/lib"
+// CHECK-X86_64: "-L{{.*}}/sysroot/usr/lib"
More information about the cfe-commits
mailing list