[PATCH] D21163: Strip Android version when looking up toolchain paths.
Josh Gao via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 9 18:21:10 PDT 2016
jmgao updated this revision to Diff 60294.
jmgao added a comment.
Add test.
http://reviews.llvm.org/D21163
Files:
lib/Driver/Driver.cpp
test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld
test/Driver/Inputs/android_triple_version/bin/arm-linux-androideabi-ld.exe
test/Driver/android-triple-version.c
Index: test/Driver/android-triple-version.c
===================================================================
--- /dev/null
+++ 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
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21163.60294.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160610/6f7d6399/attachment-0001.bin>
More information about the cfe-commits
mailing list