[PATCH] D26981: Limit maximum number of errors to 1000.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 22 10:13:27 PST 2016
ruiu created this revision.
ruiu added reviewers: rafael, davide, inglorion.
ruiu added a subscriber: llvm-commits.
This is in the context of https://llvm.org/bugs/show_bug.cgi?id=31109.
When LLD prints out errors for relocations, it tends to print out
extremely large number of errors (like millions) because it would
print out one error per relocation.
This patch makes LLD bail out if it found too many errors.
What do you think?
https://reviews.llvm.org/D26981
Files:
ELF/Driver.cpp
ELF/Error.cpp
ELF/Error.h
Index: ELF/Error.h
===================================================================
--- ELF/Error.h
+++ ELF/Error.h
@@ -31,7 +31,12 @@
namespace lld {
namespace elf {
+// The maximum number of errors. If error() is called more than
+// this number, LLD bails out. 0 means no limit.
+const unsigned ErrorLimit = 1000;
+
extern bool HasError;
+extern unsigned ErrorCount;
extern llvm::raw_ostream *ErrorOS;
extern llvm::StringRef Argv0;
Index: ELF/Error.cpp
===================================================================
--- ELF/Error.cpp
+++ ELF/Error.cpp
@@ -24,6 +24,7 @@
namespace lld {
bool elf::HasError;
+unsigned elf::ErrorCount;
raw_ostream *elf::ErrorOS;
StringRef elf::Argv0;
@@ -40,8 +41,13 @@
}
void elf::error(const Twine &Msg) {
- *ErrorOS << Argv0 << ": error: " << Msg << "\n";
+ if (ErrorLimit == 0 || ErrorCount <= ErrorLimit)
+ *ErrorOS << Argv0 << ": error: " << Msg << "\n";
+ else if (Config->ExitEarly)
+ exitLld(1);
+
HasError = true;
+ ErrorCount++;
}
void elf::error(std::error_code EC, const Twine &Prefix) {
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -43,6 +43,7 @@
bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
raw_ostream &Error) {
HasError = false;
+ ErrorCount = 0;
ErrorOS = &Error;
Argv0 = Args[0];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26981.78890.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161122/82370085/attachment.bin>
More information about the llvm-commits
mailing list