ld: Always call output_unknown_cmdline_warning

Message ID 20240125154319.788647-1-hjl.tools@gmail.com
State Accepted
Headers
Series ld: Always call output_unknown_cmdline_warning |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

H.J. Lu Jan. 25, 2024, 3:43 p.m. UTC
  Call output_unknown_cmdline_warning if there are no input files so that

$ ld -z bad-option

reports

ld: warning: -z bad-option ignored
ld: no input files

instead of

ld: no input files

	PR ld/31289
	* ldmain.c (main): Call output_unknown_cmdline_warning if there
	are no input files.
---
 ld/ldmain.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

H.J. Lu Jan. 25, 2024, 5:26 p.m. UTC | #1
On Thu, Jan 25, 2024 at 7:43 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Call output_unknown_cmdline_warning if there are no input files so that
>
> $ ld -z bad-option
>
> reports
>
> ld: warning: -z bad-option ignored
> ld: no input files
>
> instead of
>
> ld: no input files
>
>         PR ld/31289
>         * ldmain.c (main): Call output_unknown_cmdline_warning if there
>         are no input files.
> ---
>  ld/ldmain.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ld/ldmain.c b/ld/ldmain.c
> index 3b4ad144a2f..9ae541a5d82 100644
> --- a/ld/ldmain.c
> +++ b/ld/ldmain.c
> @@ -471,6 +471,7 @@ main (int argc, char **argv)
>      {
>        if (version_printed || command_line.print_output_format)
>         xexit (0);
> +      output_unknown_cmdline_warnings ();
>        einfo (_("%F%P: no input files\n"));
>      }
>
> --
> 2.43.0
>

I am checking in this.
  

Patch

diff --git a/ld/ldmain.c b/ld/ldmain.c
index 3b4ad144a2f..9ae541a5d82 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -471,6 +471,7 @@  main (int argc, char **argv)
     {
       if (version_printed || command_line.print_output_format)
 	xexit (0);
+      output_unknown_cmdline_warnings ();
       einfo (_("%F%P: no input files\n"));
     }