summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Multilib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Driver/Multilib.cpp')
-rw-r--r--clang/lib/Driver/Multilib.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index 29c633e39b1..303047e05f7 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -51,8 +51,9 @@ static void normalizePathSegment(std::string &Segment) {
}
Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
- StringRef IncludeSuffix)
- : GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix) {
+ StringRef IncludeSuffix, int Priority)
+ : GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
+ Priority(Priority) {
normalizePathSegment(this->GCCSuffix);
normalizePathSegment(this->OSSuffix);
normalizePathSegment(this->IncludeSuffix);
@@ -265,8 +266,19 @@ bool MultilibSet::select(const Multilib::flags_list &Flags, Multilib &M) const {
return true;
}
- // TODO: pick the "best" multlib when more than one is suitable
- assert(false);
+ // Sort multilibs by priority and select the one with the highest priority.
+ llvm::sort(Filtered.begin(), Filtered.end(),
+ [](const Multilib &a, const Multilib &b) -> bool {
+ return a.priority() > b.priority();
+ });
+
+ if (Filtered[0].priority() > Filtered[1].priority()) {
+ M = Filtered[0];
+ return true;
+ }
+
+ // TODO: We should consider returning llvm::Error rather than aborting.
+ assert(false && "More than one multilib with the same priority");
return false;
}
OpenPOWER on IntegriCloud