r272413 - Strip Android version when looking up toolchain paths.

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


Author: jmgao
Date: Fri Jun 10 13:30:33 2016
New Revision: 272413

URL: http://llvm.org/viewvc/llvm-project?rev=272413&view=rev
Log:
Strip Android version when looking up toolchain paths.

Summary:
Android target triples can include a version number in the abi field
(e.g. 'aarch64-linux-android21'), used for checking for availability.
However, the driver was searching for toolchain binaries using the
passed in triple as a prefix.

Reviewers: srhines, danalbert, t.p.northover

Subscribers: t.p.northover, aemerson, tberghammer, danalbert, srhines, cfe-commits

Differential Revision: http://reviews.llvm.org/D21163

Added:
    cfe/trunk/test/Driver/Inputs/android_triple_version/
    cfe/trunk/test/Driver/Inputs/android_triple_version/bin/
    cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld   (with props)
    cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld.exe   (with props)
    cfe/trunk/test/Driver/android-triple-version.c
Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=272413&r1=272412&r2=272413&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jun 10 13:30:33 2016
@@ -2343,7 +2343,15 @@ void Driver::generatePrefixedToolNames(
     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.

Added: cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld?rev=272413&view=auto
==============================================================================
    (empty)

Propchange: cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld.exe
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld.exe?rev=272413&view=auto
==============================================================================
    (empty)

Propchange: cfe/trunk/test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld.exe
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/trunk/test/Driver/android-triple-version.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-triple-version.c?rev=272413&view=auto
==============================================================================
--- cfe/trunk/test/Driver/android-triple-version.c (added)
+++ cfe/trunk/test/Driver/android-triple-version.c Fri Jun 10 13:30:33 2016
@@ -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




More information about the cfe-commits mailing list