[PATCH] D21163: Strip Android version when looking up toolchain paths.

Josh Gao via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 11:37:14 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL272413: Strip Android version when looking up toolchain paths. (authored by jmgao).

Changed prior to commit:
  http://reviews.llvm.org/D21163?vs=60294&id=60379#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21163

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld
  cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld.exe
  cfe/trunk/test/Driver/android-triple-version.c

Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2343,7 +2343,15 @@
     const char *Tool, const ToolChain &TC,
     SmallVectorImpl<std::string> &Names) const {
   // FIXME: Needs a better variable than DefaultTargetTriple
-  Names.emplace_back(DefaultTargetTriple + "-" + Tool);
+  StringRef Triple = DefaultTargetTriple;
+
+  // On Android, the target triple can include a version number that needs to
+  // be stripped.
+  if (TC.getTriple().isAndroid()) {
+    Triple = Triple.rtrim("0123456789");
+  }
+
+  Names.emplace_back((Triple + "-" + Tool).str());
   Names.emplace_back(Tool);
 
   // Allow the discovery of tools prefixed with LLVM's default target triple.
Index: cfe/trunk/test/Driver/android-triple-version.c
===================================================================
--- cfe/trunk/test/Driver/android-triple-version.c
+++ cfe/trunk/test/Driver/android-triple-version.c
@@ -0,0 +1,10 @@
+// Android's target triples can contain a version number in the environment
+// field (e.g. arm-linux-androideabi9).
+// Make sure that any version is stripped when finding toolchain binaries.
+
+// RUN: env "PATH=%S/Inputs/android_triple_version/bin" \
+// RUN:     %clang -### -target arm-linux-androideabi %s 2>&1 | FileCheck %s
+// RUN: env "PATH=%S/Inputs/android_triple_version/bin" \
+// RUN:     %clang -### -target arm-linux-androideabi9 %s 2>&1 | FileCheck %s
+
+// CHECK: arm-linux-androideabi-ld


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21163.60379.patch
Type: text/x-patch
Size: 1556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160610/a6f8b656/attachment.bin>


More information about the cfe-commits mailing list