Apple ld64 and llvm-project ld64.lld support -w to suppress warnings. -w was picked likely because compiler drivers use -w to suppress warnings. I think -w mildly benefits GNU ld/gold as well. With --noinhibit-exec, we downgrade errors to warnings. 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. Since we know the output otherwise does not link, the warnings are not useful. If we have -w, we can add -w to not see the unuseful warnings.
Created attachment 14403 [details] Proposed patch Hi Fanguri, Is this patch the kind of thing that you had in mind ? Cheers Nick
(In reply to Nick Clifton from comment #1) > Created attachment 14403 [details] > Proposed patch > > Hi Fanguri, > > Is this patch the kind of thing that you had in mind ? > > Cheers > Nick Hi Nick, thanks for sending a patch! This looks good with just one thought: `config.fatal_warnings = false;` makes me wonder how -w interacts with --fatal-warnings. It seems that -w --fatal-warnings and --fatal-warnings -w have the same effect (-w wins, which makes sense IMO), so I guess `config.fatal_warnings = false;` can be omitted.
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4b2e7a577c2f7311a8c381ff791d46e654c41fcc commit 4b2e7a577c2f7311a8c381ff791d46e654c41fcc Author: Nick Clifton <nickc@redhat.com> Date: Fri Oct 21 12:20:09 2022 +0100 Add a -w option to the linker to suppress warning and error messages. PR 29654 * ld.h (struct ld_config_type): Add no_warnings field. * ldlex.h (enum option_values): Add OPTION_NO_WARNINGS. * lexsup.c (ld_options): Add --no-warnings. (parse_args): Add support for -w and --no-warnings. * ldmisc.c (vfinfo): Return early if the message is a warning and -w has been enabled. * ld.texi (options): Document new command line option. * NEWS: Mention the new feature.
Hi Fangrui, > `config.fatal_warnings = false;` makes me wonder how -w interacts with > --fatal-warnings. It seems that -w --fatal-warnings and --fatal-warnings -w > have the same effect (-w wins, which makes sense IMO), so I guess > `config.fatal_warnings = false;` can be omitted. It could, but I feel that it helps to emphasize that -w takes precedence over --fatal-warnings, so I have left it in. Cheers Nick