-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Multilib error fixes #110804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multilib error fixes #110804
Changes from 2 commits
531253a
9401c95
6acc753
e922217
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,10 +32,9 @@ using namespace llvm::sys; | |
|
|
||
| Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix, | ||
| StringRef IncludeSuffix, const flags_list &Flags, | ||
| StringRef ExclusiveGroup, | ||
| std::optional<StringRef> FatalError) | ||
| StringRef ExclusiveGroup, std::optional<StringRef> Error) | ||
| : GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix), | ||
| Flags(Flags), ExclusiveGroup(ExclusiveGroup), FatalError(FatalError) { | ||
| Flags(Flags), ExclusiveGroup(ExclusiveGroup), Error(Error) { | ||
| assert(GCCSuffix.empty() || | ||
| (StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1)); | ||
| assert(OSSuffix.empty() || | ||
|
|
@@ -100,6 +99,7 @@ bool MultilibSet::select(const Driver &D, const Multilib::flags_list &Flags, | |
| llvm::SmallVectorImpl<Multilib> &Selected) const { | ||
| llvm::StringSet<> FlagSet(expandFlags(Flags)); | ||
| Selected.clear(); | ||
| bool AnyErrors = false; | ||
|
|
||
| // Decide which multilibs we're going to select at all. | ||
| llvm::DenseSet<StringRef> ExclusiveGroupsSelected; | ||
|
|
@@ -124,12 +124,11 @@ bool MultilibSet::select(const Driver &D, const Multilib::flags_list &Flags, | |
| } | ||
|
|
||
| // If this multilib is actually a placeholder containing a fatal | ||
| // error message written by the multilib.yaml author, display that | ||
| // error message, and return failure. | ||
| if (M.isFatalError()) { | ||
| D.Diag(clang::diag::err_drv_multilib_custom_error) << M.getFatalError(); | ||
| return false; | ||
| } | ||
| // error message written by the multilib.yaml author, then set a | ||
| // flag that will cause a failure return. Our caller will display | ||
| // the error message. | ||
| if (M.isError()) | ||
| AnyErrors = true; | ||
|
|
||
| // Select this multilib. | ||
| Selected.push_back(M); | ||
|
|
@@ -139,7 +138,7 @@ bool MultilibSet::select(const Driver &D, const Multilib::flags_list &Flags, | |
| // round. | ||
| std::reverse(Selected.begin(), Selected.end()); | ||
|
|
||
| return !Selected.empty(); | ||
| return !AnyErrors && !Selected.empty(); | ||
| } | ||
|
|
||
| llvm::StringSet<> | ||
|
|
@@ -173,7 +172,7 @@ static const VersionTuple MultilibVersionCurrent(1, 0); | |
|
|
||
| struct MultilibSerialization { | ||
| std::string Dir; // if this record successfully selects a library dir | ||
| std::string FatalError; // if this record reports a fatal error message | ||
| std::string Error; // if this record reports a fatal error message | ||
| std::vector<std::string> Flags; | ||
| std::string Group; | ||
| }; | ||
|
|
@@ -217,15 +216,15 @@ struct MultilibSetSerialization { | |
| template <> struct llvm::yaml::MappingTraits<MultilibSerialization> { | ||
| static void mapping(llvm::yaml::IO &io, MultilibSerialization &V) { | ||
| io.mapOptional("Dir", V.Dir); | ||
| io.mapOptional("FatalError", V.FatalError); | ||
| io.mapOptional("Error", V.Error); | ||
| io.mapRequired("Flags", V.Flags); | ||
| io.mapOptional("Group", V.Group); | ||
| } | ||
| static std::string validate(IO &io, MultilibSerialization &V) { | ||
| if (V.Dir.empty() && V.FatalError.empty()) | ||
| return "one of the 'Dir' and 'FatalError' keys must be specified"; | ||
| if (!V.Dir.empty() && !V.FatalError.empty()) | ||
| return "the 'Dir' and 'FatalError' keys may not both be specified"; | ||
| if (V.Dir.empty() && V.Error.empty()) | ||
| return "one of the 'Dir' and 'atalError' keys must be specified"; | ||
|
||
| if (!V.Dir.empty() && !V.Error.empty()) | ||
| return "the 'Dir' and 'Error' keys may not both be specified"; | ||
| if (StringRef(V.Dir).starts_with("/")) | ||
| return "paths must be relative but \"" + V.Dir + "\" starts with \"/\""; | ||
| return std::string{}; | ||
|
|
@@ -311,8 +310,8 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input, | |
| multilib_list Multilibs; | ||
| Multilibs.reserve(MS.Multilibs.size()); | ||
| for (const auto &M : MS.Multilibs) { | ||
| if (!M.FatalError.empty()) { | ||
| Multilibs.emplace_back("", "", "", M.Flags, M.Group, M.FatalError); | ||
| if (!M.Error.empty()) { | ||
| Multilibs.emplace_back("", "", "", M.Flags, M.Group, M.Error); | ||
| } else { | ||
| std::string Dir; | ||
| if (M.Dir != ".") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the line above, should that be "containing an error message written ... " rather than fatal error?