[ELF2] Output of all unknown arguments instead of only one.

Patch from George Rimar!

llvm-svn: 248524
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index a08a8bd..8d7ef5e 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -58,7 +58,12 @@
     error(Twine("missing arg value for \"") + Args.getArgString(MissingIndex) +
           "\", expected " + Twine(MissingCount) +
           (MissingCount == 1 ? " argument.\n" : " arguments"));
-  for (auto *Arg : Args.filtered(OPT_UNKNOWN))
-    error(Twine("unknown argument: ") + Arg->getSpelling());
+
+  iterator_range<opt::arg_iterator> Unknowns = Args.filtered(OPT_UNKNOWN);
+  for (auto *Arg : Unknowns)
+    warning("warning: unknown argument: " + Arg->getSpelling());
+  if (Unknowns.begin() != Unknowns.end())
+    error("unknown argument(s) found");
+
   return Args;
 }
diff --git a/lld/ELF/Error.cpp b/lld/ELF/Error.cpp
index 11721b0..e0701f7 100644
--- a/lld/ELF/Error.cpp
+++ b/lld/ELF/Error.cpp
@@ -15,6 +15,8 @@
 namespace lld {
 namespace elf2 {
 
+void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
+
 void error(const Twine &Msg) {
   llvm::errs() << Msg << "\n";
   exit(1);
diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h
index b086434..b1d2e7a 100644
--- a/lld/ELF/Error.h
+++ b/lld/ELF/Error.h
@@ -15,6 +15,8 @@
 namespace lld {
 namespace elf2 {
 
+void warning(const Twine &Msg);
+
 LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg);
 void error(std::error_code EC, const Twine &Prefix);
 void error(std::error_code EC);