diff options
Diffstat (limited to 'lib/Driver/Multilib.cpp')
-rw-r--r-- | lib/Driver/Multilib.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/Driver/Multilib.cpp b/lib/Driver/Multilib.cpp index 178a60db60e5..303047e05f78 100644 --- a/lib/Driver/Multilib.cpp +++ b/lib/Driver/Multilib.cpp @@ -1,9 +1,8 @@ //===- Multilib.cpp - Multilib Implementation -----------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -52,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); @@ -266,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; } |