Skip to content

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

Closed
wants to merge 4 commits into from
Closed

Conversation

statham-arm
Copy link
Collaborator

This PR contains two separate patches updating the "custom error message" feature in multilib.yaml (#105684):

  • Change the YAML keyword FatalError to Error, as @petrhosek requested after the previous PR was already landed
  • Improve ergonomics of the error report: it's better to have it after the long list of available multilibs, not before, so that it appears in the most sensible place for a fatal error message and doesn't get scrolled off the user's screen.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Oct 2, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2024

@llvm/pr-subscribers-clang-driver

Author: Simon Tatham (statham-arm)

Changes

This PR contains two separate patches updating the "custom error message" feature in multilib.yaml (#105684):

  • Change the YAML keyword FatalError to Error, as @petrhosek requested after the previous PR was already landed
  • Improve ergonomics of the error report: it's better to have it after the long list of available multilibs, not before, so that it appears in the most sensible place for a fatal error message and doesn't get scrolled off the user's screen.

Full diff: https://github.com/llvm/llvm-project/pull/110804.diff

7 Files Affected:

  • (modified) clang/docs/Multilib.rst (+2-2)
  • (modified) clang/include/clang/Driver/Multilib.h (+4-4)
  • (modified) clang/lib/Driver/Driver.cpp (+1-1)
  • (modified) clang/lib/Driver/Multilib.cpp (+17-17)
  • (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+17-1)
  • (modified) clang/test/Driver/baremetal-multilib-custom-error.yaml (+1-1)
  • (modified) clang/unittests/Driver/MultilibTest.cpp (+1-1)
diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index 6d77fda3623b20..7637d0db9565b8 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -202,8 +202,8 @@ For a more comprehensive example see
 
   # If there is no multilib available for a particular set of flags, and the
   # other multilibs are not adequate fallbacks, then you can define a variant
-  # record with a FatalError key in place of the Dir key.
-  - FatalError: this multilib collection has no hard-float ABI support 
+  # record with an Error key in place of the Dir key.
+  - Error: this multilib collection has no hard-float ABI support
     Flags: [--target=thumbv7m-none-eabi, -mfloat-abi=hard]
 
 
diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h
index 1a79417111eece..dbed70f4f9008f 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -54,7 +54,7 @@ class Multilib {
   // Some Multilib objects don't actually represent library directories you can
   // select. Instead, they represent failures of multilib selection, of the
   // form 'Sorry, we don't have any library compatible with these constraints'.
-  std::optional<std::string> FatalError;
+  std::optional<std::string> Error;
 
 public:
   /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
@@ -63,7 +63,7 @@ class Multilib {
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
            StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(),
            StringRef ExclusiveGroup = {},
-           std::optional<StringRef> FatalError = std::nullopt);
+           std::optional<StringRef> Error = std::nullopt);
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -94,9 +94,9 @@ class Multilib {
 
   bool operator==(const Multilib &Other) const;
 
-  bool isFatalError() const { return FatalError.has_value(); }
+  bool isError() const { return Error.has_value(); }
 
-  const std::string &getFatalError() const { return FatalError.value(); }
+  const std::string &getErrorMessage() const { return Error.value(); }
 };
 
 raw_ostream &operator<<(raw_ostream &OS, const Multilib &M);
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index fba6a8853c3960..b8536a706a8fa2 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2314,7 +2314,7 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
 
   if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
     for (const Multilib &Multilib : TC.getMultilibs())
-      if (!Multilib.isFatalError())
+      if (!Multilib.isError())
         llvm::outs() << Multilib << "\n";
     return false;
   }
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index e8a27fe9de473a..fbf62da132c3b9 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -33,9 +33,9 @@ using namespace llvm::sys;
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
                    StringRef IncludeSuffix, const flags_list &Flags,
                    StringRef ExclusiveGroup,
-                   std::optional<StringRef> FatalError)
+                   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 +100,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 +125,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 +139,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 +173,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 +217,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 +311,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 != ".")
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 8aed9ed6e18817..75ca0552ce63a5 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -186,10 +186,26 @@ static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
     return;
   D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
   std::stringstream ss;
+
+  // If multilib selection didn't complete successfully, report a list
+  // of all the configurations the user could have provided.
   for (const Multilib &Multilib : Result.Multilibs)
-    if (!Multilib.isFatalError())
+    if (!Multilib.isError())
       ss << "\n" << llvm::join(Multilib.flags(), " ");
   D.Diag(clang::diag::note_drv_available_multilibs) << ss.str();
+
+  // Now report any custom error messages requested by the YAML. We do
+  // this after displaying the list of available multilibs, because
+  // that list is probably large, and (in interactive use) risks
+  // scrolling the useful error message off the top of the user's
+  // terminal.
+  for (const Multilib &Multilib : Result.SelectedMultilibs)
+    if (Multilib.isError())
+      D.Diag(clang::diag::err_drv_multilib_custom_error) << Multilib.getErrorMessage();
+
+  // If there was an error, clear the SelectedMultilibs vector, in
+  // case it contains partial data.
+  Result.SelectedMultilibs.clear();
 }
 
 static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml";
diff --git a/clang/test/Driver/baremetal-multilib-custom-error.yaml b/clang/test/Driver/baremetal-multilib-custom-error.yaml
index c006bb4072ce2f..761e595757f346 100644
--- a/clang/test/Driver/baremetal-multilib-custom-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-custom-error.yaml
@@ -44,7 +44,7 @@ Variants:
   Flags:
   - --target=thumbv8.1m.main-unknown-none-eabi
 
-- FatalError: mve-softfloat is not supported
+- Error: mve-softfloat is not supported
   Flags: 
   - --target=thumbv8.1m.main-unknown-none-eabi
   - -march=thumbv8.1m.main+mve
diff --git a/clang/unittests/Driver/MultilibTest.cpp b/clang/unittests/Driver/MultilibTest.cpp
index dfeef7c2077c72..c03e117d993045 100644
--- a/clang/unittests/Driver/MultilibTest.cpp
+++ b/clang/unittests/Driver/MultilibTest.cpp
@@ -282,7 +282,7 @@ Variants: []
 )"));
   EXPECT_TRUE(
       StringRef(Diagnostic)
-          .contains("one of the 'Dir' and 'FatalError' keys must be specified"))
+          .contains("one of the 'Dir' and 'Error' keys must be specified"))
       << Diagnostic;
 
   EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(

@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2024

@llvm/pr-subscribers-clang

Author: Simon Tatham (statham-arm)

Changes

This PR contains two separate patches updating the "custom error message" feature in multilib.yaml (#105684):

  • Change the YAML keyword FatalError to Error, as @petrhosek requested after the previous PR was already landed
  • Improve ergonomics of the error report: it's better to have it after the long list of available multilibs, not before, so that it appears in the most sensible place for a fatal error message and doesn't get scrolled off the user's screen.

Full diff: https://github.com/llvm/llvm-project/pull/110804.diff

7 Files Affected:

  • (modified) clang/docs/Multilib.rst (+2-2)
  • (modified) clang/include/clang/Driver/Multilib.h (+4-4)
  • (modified) clang/lib/Driver/Driver.cpp (+1-1)
  • (modified) clang/lib/Driver/Multilib.cpp (+17-17)
  • (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+17-1)
  • (modified) clang/test/Driver/baremetal-multilib-custom-error.yaml (+1-1)
  • (modified) clang/unittests/Driver/MultilibTest.cpp (+1-1)
diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index 6d77fda3623b20..7637d0db9565b8 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -202,8 +202,8 @@ For a more comprehensive example see
 
   # If there is no multilib available for a particular set of flags, and the
   # other multilibs are not adequate fallbacks, then you can define a variant
-  # record with a FatalError key in place of the Dir key.
-  - FatalError: this multilib collection has no hard-float ABI support 
+  # record with an Error key in place of the Dir key.
+  - Error: this multilib collection has no hard-float ABI support
     Flags: [--target=thumbv7m-none-eabi, -mfloat-abi=hard]
 
 
diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h
index 1a79417111eece..dbed70f4f9008f 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -54,7 +54,7 @@ class Multilib {
   // Some Multilib objects don't actually represent library directories you can
   // select. Instead, they represent failures of multilib selection, of the
   // form 'Sorry, we don't have any library compatible with these constraints'.
-  std::optional<std::string> FatalError;
+  std::optional<std::string> Error;
 
 public:
   /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
@@ -63,7 +63,7 @@ class Multilib {
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
            StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(),
            StringRef ExclusiveGroup = {},
-           std::optional<StringRef> FatalError = std::nullopt);
+           std::optional<StringRef> Error = std::nullopt);
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -94,9 +94,9 @@ class Multilib {
 
   bool operator==(const Multilib &Other) const;
 
-  bool isFatalError() const { return FatalError.has_value(); }
+  bool isError() const { return Error.has_value(); }
 
-  const std::string &getFatalError() const { return FatalError.value(); }
+  const std::string &getErrorMessage() const { return Error.value(); }
 };
 
 raw_ostream &operator<<(raw_ostream &OS, const Multilib &M);
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index fba6a8853c3960..b8536a706a8fa2 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2314,7 +2314,7 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
 
   if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
     for (const Multilib &Multilib : TC.getMultilibs())
-      if (!Multilib.isFatalError())
+      if (!Multilib.isError())
         llvm::outs() << Multilib << "\n";
     return false;
   }
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index e8a27fe9de473a..fbf62da132c3b9 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -33,9 +33,9 @@ using namespace llvm::sys;
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
                    StringRef IncludeSuffix, const flags_list &Flags,
                    StringRef ExclusiveGroup,
-                   std::optional<StringRef> FatalError)
+                   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 +100,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 +125,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 +139,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 +173,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 +217,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 +311,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 != ".")
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 8aed9ed6e18817..75ca0552ce63a5 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -186,10 +186,26 @@ static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
     return;
   D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
   std::stringstream ss;
+
+  // If multilib selection didn't complete successfully, report a list
+  // of all the configurations the user could have provided.
   for (const Multilib &Multilib : Result.Multilibs)
-    if (!Multilib.isFatalError())
+    if (!Multilib.isError())
       ss << "\n" << llvm::join(Multilib.flags(), " ");
   D.Diag(clang::diag::note_drv_available_multilibs) << ss.str();
+
+  // Now report any custom error messages requested by the YAML. We do
+  // this after displaying the list of available multilibs, because
+  // that list is probably large, and (in interactive use) risks
+  // scrolling the useful error message off the top of the user's
+  // terminal.
+  for (const Multilib &Multilib : Result.SelectedMultilibs)
+    if (Multilib.isError())
+      D.Diag(clang::diag::err_drv_multilib_custom_error) << Multilib.getErrorMessage();
+
+  // If there was an error, clear the SelectedMultilibs vector, in
+  // case it contains partial data.
+  Result.SelectedMultilibs.clear();
 }
 
 static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml";
diff --git a/clang/test/Driver/baremetal-multilib-custom-error.yaml b/clang/test/Driver/baremetal-multilib-custom-error.yaml
index c006bb4072ce2f..761e595757f346 100644
--- a/clang/test/Driver/baremetal-multilib-custom-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-custom-error.yaml
@@ -44,7 +44,7 @@ Variants:
   Flags:
   - --target=thumbv8.1m.main-unknown-none-eabi
 
-- FatalError: mve-softfloat is not supported
+- Error: mve-softfloat is not supported
   Flags: 
   - --target=thumbv8.1m.main-unknown-none-eabi
   - -march=thumbv8.1m.main+mve
diff --git a/clang/unittests/Driver/MultilibTest.cpp b/clang/unittests/Driver/MultilibTest.cpp
index dfeef7c2077c72..c03e117d993045 100644
--- a/clang/unittests/Driver/MultilibTest.cpp
+++ b/clang/unittests/Driver/MultilibTest.cpp
@@ -282,7 +282,7 @@ Variants: []
 )"));
   EXPECT_TRUE(
       StringRef(Diagnostic)
-          .contains("one of the 'Dir' and 'FatalError' keys must be specified"))
+          .contains("one of the 'Dir' and 'Error' keys must be specified"))
       << Diagnostic;
 
   EXPECT_FALSE(parseYaml(MS, Diagnostic, YAML_PREAMBLE R"(

Copy link

github-actions bot commented Oct 2, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

This is a late-breaking change to llvm#105684, suggested after the
original patch was already landed.
If `multilib.yaml` reports a custom error message for some unsupported
configuration, it's not very helpful to display that error message
_first_, and then follow it up with a huge list of all the multilib
configurations that _are_ supported.

In interactive use, the list is likely to scroll the most important
message off the top of the user's window, leaving them with just a
long list of available libraries, without a visible explanation of
_why_ clang just printed that long list. Also, in general, it makes
more intuitive sense to print the message last that shows why
compilation can't continue, because that's where users are most likely
to look for the reason why something stopped.
@statham-arm statham-arm force-pushed the multilib-error-fixes branch from 765e431 to 9401c95 Compare October 2, 2024 08:51
Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me. A few small comment nits.

D.Diag(clang::diag::err_drv_multilib_custom_error) << M.getFatalError();
return false;
}
// error message written by the multilib.yaml author, then set a
Copy link
Collaborator

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?

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";
Copy link
Collaborator

@smithp35 smithp35 Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'atalError' looks like a typo. It probably means we're missing a test for that message too.

Actually it looks like the tests are failing in pre-commit so there's no missing tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha – that's what I get for checking I'd caught them all by grepping for Fatal. The grep missed this one! (And also the lower-case one you pointed out before.)

Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. I don't have any more comments. I've approved the patch on my side. Will be worth waiting for a bit to see if any other reviewers have any feedback.

Copy link
Member

@petrhosek petrhosek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the change!

statham-arm added a commit that referenced this pull request Oct 7, 2024
…110804)

This is a late-breaking change to #105684, suggested after the
original patch was already landed.
statham-arm added a commit that referenced this pull request Oct 7, 2024
If `multilib.yaml` reports a custom error message for some unsupported
configuration, it's not very helpful to display that error message
_first_, and then follow it up with a huge list of all the multilib
configurations that _are_ supported.

In interactive use, the list is likely to scroll the most important
message off the top of the user's window, leaving them with just a
long list of available libraries, without a visible explanation of
_why_ clang just printed that long list. Also, in general, it makes
more intuitive sense to print the message last that shows why
compilation can't continue, because that's where users are most likely
to look for the reason why something stopped.
@statham-arm statham-arm closed this Oct 7, 2024
@statham-arm statham-arm deleted the multilib-error-fixes branch October 7, 2024 08:36
statham-arm added a commit to statham-arm/LLVM-embedded-toolchain-for-Arm that referenced this pull request Oct 7, 2024
LLVM PR llvm/llvm-project#110804 made this
change at the request of a code reviewer of the original patch.
statham-arm added a commit to ARM-software/LLVM-embedded-toolchain-for-Arm that referenced this pull request Oct 7, 2024
LLVM PR llvm/llvm-project#110804 made this
change at the request of a code reviewer of the original patch.
Kyvangka1610 added a commit to Kyvangka1610/llvm-project that referenced this pull request Oct 7, 2024
* commit 'FETCH_HEAD':
  [X86] getIntImmCostInst - pull out repeated Imm.getBitWidth() calls. NFC.
  [X86] Add test coverage for llvm#111323
  [Driver] Use empty multilib file in another test (llvm#111352)
  [clang][OpenMP][test] Use x86_64-linux-gnu triple for test referencing avx512f feature (llvm#111337)
  [doc] Fix Kaleidoscope tutorial chapter 3 code snippet and full listing discrepancies (llvm#111289)
  [Flang][OpenMP] Improve entry block argument creation and binding (llvm#110267)
  [x86] combineMul - handle 0/-1 KnownBits cases before MUL_IMM logic (REAPPLIED)
  [llvm-dis] Fix non-deterministic disassembly across multiple inputs (llvm#110988)
  [lldb][test] TestDataFormatterLibcxxOptionalSimulator.py: change order of ifdefs
  [lldb][test] Add libcxx-simulators test for std::optional (llvm#111133)
  [x86] combineMul - use computeKnownBits directly to find MUL_IMM constant splat. (REAPPLIED)
  Reland "[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout" (llvm#111123)
  Revert "[x86] combineMul - use computeKnownBits directly to find MUL_IMM constant splat."
  update_test_checks: fix a simple regression  (llvm#111347)
  [LegalizeVectorTypes] Always widen fabs (llvm#111298)
  [lsan] Make ReportUnsuspendedThreads return bool also for Fuchsia
  [mlir][vector] Add more tests for ConvertVectorToLLVM (6/n) (llvm#111121)
  [bazel] port 9144fed
  [SystemZ] Remove inlining threshold multiplier. (llvm#106058)
  [LegalizeVectorTypes] When widening don't check for libcalls if promoted (llvm#111297)
  [clang][Driver] Improve multilib custom error reporting (llvm#110804)
  [clang][Driver] Rename "FatalError" key to "Error" in multilib.yaml (llvm#110804)
  [LLVM][Maintainers] Update release managers (llvm#111164)
  [Clang][Driver] Add option to provide path for multilib's YAML config file (llvm#109640)
  [LoopVectorize] Remove redundant code in emitSCEVChecks (llvm#111132)
  [AMDGPU] Only emit SCOPE_SYS global_wb (llvm#110636)
  [ELF] Change Ctx::target to unique_ptr (llvm#111260)
  [ELF] Pass Ctx & to some free functions
  [RISCV] Only disassemble fcvtmod.w.d if the rounding mode is rtz. (llvm#111308)
  [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d76 (llvm#111277)
  [ELF] Pass Ctx & to InputFile
  [clang-format] Add AlignFunctionDeclarations to AlignConsecutiveDeclarations (llvm#108241)
  [AMDGPU] Support preloading hidden kernel arguments (llvm#98861)
  [ELF] Move static nextGroupId isInGroup to LinkerDriver
  [clangd] Add ArgumentLists config option under Completion (llvm#111322)
  [ELF] Pass Ctx & to SyntheticSections
  [ELF] Pass Ctx & to Symbols
  [ELF] Pass Ctx & to Symbols
  [ELF] getRelocTargetVA: pass Ctx and Relocation. NFC
  [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (llvm#111282)
  [VPlan] Use pointer to member 0 as VPInterleaveRecipe's pointer arg. (llvm#106431)
  [clangd] Simplify ternary expressions with std::optional::value_or (NFC) (llvm#111309)
  [libc++][format][2/3] Optimizes c-string arguments. (llvm#101805)
  [RISCV] Combine RVBUnary and RVKUnary into classes that are more similar to ALU(W)_r(r/i). NFC (llvm#111279)
  [ELF] Pass Ctx & to InputFiles
  [libc] GPU RPC interface: add return value to `rpc_host_call` (llvm#111288)

Signed-off-by: kyvangka1610 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants