Skip to content

Commit c0e4020

Browse files
committed
[lld-macho] Implement -fatal_warnings
Differential Revision: https://reviews.llvm.org/D91894
1 parent bfd2c21 commit c0e4020

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

lld/MachO/DriverUtils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
7676
cl::ExpandResponseFiles(saver, cl::TokenizeGNUCommandLine, vec);
7777
opt::InputArgList args = ParseArgs(vec, missingIndex, missingCount);
7878

79+
// Handle -fatal_warnings early since it converts missing argument warnings
80+
// to errors.
81+
errorHandler().fatalWarnings = args.hasArg(OPT_fatal_warnings);
82+
7983
if (missingCount)
8084
error(Twine(args.getArgString(missingIndex)) + ": missing argument");
8185

lld/MachO/Options.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ def no_application_extension : Flag<["-"], "no_application_extension">,
610610
Flags<[HelpHidden]>,
611611
Group<grp_rare>;
612612
def fatal_warnings : Flag<["-"], "fatal_warnings">,
613-
HelpText<"Escalate warnings as errors">,
614-
Flags<[HelpHidden]>,
613+
HelpText<"Treat warnings as errors">,
615614
Group<grp_rare>;
616615
def no_eh_labels : Flag<["-"], "no_eh_labels">,
617616
HelpText<"In -r mode, suppress .eh labels in the __eh_frame section">,

lld/test/MachO/fatal-warnings.s

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# REQUIRES: x86
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t1.o
3+
4+
# RUN: %lld %t1.o -o /dev/null -single_module 2>&1 \
5+
# RUN: | FileCheck -check-prefix=WARNING %s
6+
# RUN: not %lld %t1.o -fatal_warnings -o /dev/null -single_module 2>&1 \
7+
# RUN: | FileCheck -check-prefix=ERROR %s
8+
9+
# ERROR: error: Option `-single_module' is deprecated
10+
# WARNING: warning: Option `-single_module' is deprecated
11+
12+
.globl _main
13+
_main:

0 commit comments

Comments
 (0)