[PATCH] D136569: [ELF] Add --no-warnings/-w
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 23 16:23:13 PDT 2022
MaskRay created this revision.
MaskRay added a reviewer: peter.smith.
Herald added subscribers: StephenFan, arichardson, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Mach-O ld64 supports -w to suppress warnings. GNU ld 2.40 will support the
option as well (https://sourceware.org/bugzilla/show_bug.cgi?id=29654).
This feature has some small value. E.g. when analyzing a large executable with
relocation overflow issues, we may use --noinhibit-exec --emit-relocs to get
relocations and an output file despite relocation overflow issues. -w can significantly
improve the link time as printing the massive warnings is slow.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136569
Files:
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/docs/ReleaseNotes.rst
lld/docs/ld.lld.1
lld/test/ELF/fatal-warnings.s
lld/test/ELF/no-inhibit-exec.s
lld/test/ELF/warnings.s
Index: lld/test/ELF/warnings.s
===================================================================
--- lld/test/ELF/warnings.s
+++ lld/test/ELF/warnings.s
@@ -9,6 +9,10 @@
# RUN: not ld.lld --warn-common --fatal-warnings %t1.o %t2.o -o /dev/null 2>&1 | \
# RUN: FileCheck -check-prefix=ERR %s
+## --no-warnings/-w suppresses warnings and cancel --fatal-warnings.
+# RUN: ld.lld --no-warnings --warn-common %t1.o %t2.o -o /dev/null 2>&1 | count 0
+# RUN: ld.lld -w --fatal-warnings --warn-common %t1.o %t2.o -o /dev/null 2>&1 | count 0
+
.globl _start
_start:
Index: lld/test/ELF/no-inhibit-exec.s
===================================================================
--- lld/test/ELF/no-inhibit-exec.s
+++ lld/test/ELF/no-inhibit-exec.s
@@ -5,6 +5,8 @@
# RUN: llvm-objdump -d %t2 | FileCheck %s
# RUN: llvm-readobj -r %t2 | FileCheck %s --check-prefix=RELOC
+# RUN: ld.lld %t -w --noinhibit-exec -o /dev/null 2>&1 | count 0
+
# CHECK: Disassembly of section .text:
# CHECK-EMPTY:
# CHECK-NEXT: _start
Index: lld/docs/ld.lld.1
===================================================================
--- lld/docs/ld.lld.1
+++ lld/docs/ld.lld.1
@@ -358,6 +358,9 @@
Report unresolved symbols even if the linker is creating a shared library.
.It Fl -no-warn-symbol-ordering
Do not warn about problems with the symbol ordering file or call graph profile.
+.It Fl -no-warnings , Fl w
+Suppress warnings and cancel
+.Cm --fatal-warnings.
.It Fl -no-whole-archive
Restores the default behavior of loading archive members.
.It Fl -no-pie , Fl -no-pic-executable
Index: lld/docs/ReleaseNotes.rst
===================================================================
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -31,6 +31,7 @@
* ``--compress-debug-sections=zstd`` is now available to compress debug
sections with zstd (``ELFCOMPRESS_ZSTD``).
(`D133548 <https://reviews.llvm.org/D133548>`_)
+* ``--no-warnings``/``-w`` is now available to suppress warnings.
Breaking changes
----------------
Index: lld/ELF/Options.td
===================================================================
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -297,6 +297,9 @@
def no_undefined: F<"no-undefined">,
HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
+def no_warnings: FF<"no-warnings">, HelpText<"Suppress warnings and cancel --fatal-warnings">;
+def : Flag<["-"], "w">, Alias<no_warnings>, HelpText<"Alias for --no-warnings">;
+
def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
HelpText<"Path to file to write output">;
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -542,7 +542,9 @@
// Interpret these flags early because error()/warn() depend on them.
errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20);
errorHandler().fatalWarnings =
- args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false);
+ args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false) &&
+ !args.hasArg(OPT_no_warnings);
+ errorHandler().suppressWarnings = args.hasArg(OPT_no_warnings);
checkZOptions(args);
// Handle -help
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136569.470021.patch
Type: text/x-patch
Size: 3238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221023/990600c8/attachment.bin>
More information about the llvm-commits
mailing list