diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp --- a/lld/Common/ErrorHandler.cpp +++ b/lld/Common/ErrorHandler.cpp @@ -242,6 +242,9 @@ return; } + if (suppressWarnings) + return; + std::lock_guard lock(mu); reportDiagnostic(getLocation(msg), Colors::MAGENTA, "warning", msg); sep = getSeparator(msg); diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp --- a/lld/MachO/DriverUtils.cpp +++ b/lld/MachO/DriverUtils.cpp @@ -87,6 +87,7 @@ // Handle -fatal_warnings early since it converts missing argument warnings // to errors. errorHandler().fatalWarnings = args.hasArg(OPT_fatal_warnings); + errorHandler().suppressWarnings = args.hasArg(OPT_w); if (missingCount) error(Twine(args.getArgString(missingIndex)) + ": missing argument"); diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -887,7 +887,6 @@ Group; def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, - Flags<[HelpHidden]>, Group; def final_output : Separate<["-"], "final_output">, MetaVarName<"">, diff --git a/lld/include/lld/Common/ErrorHandler.h b/lld/include/lld/Common/ErrorHandler.h --- a/lld/include/lld/Common/ErrorHandler.h +++ b/lld/include/lld/Common/ErrorHandler.h @@ -101,6 +101,7 @@ StringRef logName = "lld"; bool exitEarly = true; bool fatalWarnings = false; + bool suppressWarnings = false; bool verbose = false; bool vsDiagnostics = false; bool disableOutput = false; diff --git a/lld/test/MachO/fatal-warnings.s b/lld/test/MachO/fatal-warnings.s --- a/lld/test/MachO/fatal-warnings.s +++ b/lld/test/MachO/fatal-warnings.s @@ -6,6 +6,12 @@ # RUN: not %no-fatal-warnings-lld %t1.o -fatal_warnings -o /dev/null \ # RUN: -single_module 2>&1 | FileCheck -check-prefix=ERROR %s +# RUN: %no-fatal-warnings-lld %t1.o -w -o /dev/null -single_module 2>&1 \ +# RUN: | count 0 +# RUN: not %no-fatal-warnings-lld %t1.o -fatal_warnings -w -o /dev/null \ +# RUN: -single_module 2>&1 \ +# RUN: | FileCheck --check-prefix=ERROR %s + # ERROR: error: Option `-single_module' is deprecated # WARNING: warning: Option `-single_module' is deprecated