[RFC,1/3] gas: defer printing version ID

Message ID 9be71c9f-4399-4898-87e8-18ae9af03728@suse.com
State New
Headers
Series gas: pre-defined symbols and .errif / .warnif |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Jan Beulich Dec. 9, 2024, 9:20 a.m. UTC
  In order to be able to silence earlier uses of -v, don't print while
processing command line arguments; defer until all options were consumed
or we're about the exit (leaving alone all paths reaching as_fatal()).
  

Patch

--- a/gas/as.c
+++ b/gas/as.c
@@ -631,7 +631,6 @@  parse_args (int * pargc, char *** pargv)
 	  if (optc == 'v')
 	    {
 	case 'v':
-	      print_version_id ();
 	      verbose = 1;
 	      break;
 	    }
@@ -644,6 +643,8 @@  parse_args (int * pargc, char *** pargv)
 	  /* Fall through.  */
 
 	case '?':
+	  if (verbose > 0)
+	    print_version_id ();
 	  exit (EXIT_FAILURE);
 
 	case 1:			/* File name.  */
@@ -654,10 +655,14 @@  parse_args (int * pargc, char *** pargv)
 	  break;
 
 	case OPTION_TARGET_HELP:
+	  if (verbose > 0)
+	    print_version_id ();
 	  md_show_usage (stdout);
 	  exit (EXIT_SUCCESS);
 
 	case OPTION_HELP:
+	  if (verbose > 0)
+	    print_version_id ();
 	  show_usage (stdout);
 	  exit (EXIT_SUCCESS);
 
@@ -694,6 +699,8 @@  parse_args (int * pargc, char *** pargv)
 	  break;
 
 	case OPTION_VERSION:
+	  if (verbose > 0)
+	    print_version_id ();
 	  /* This output is intended to follow the GNU standards document.  */
 	  printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
 	  printf (_("Copyright (C) 2024 Free Software Foundation, Inc.\n"));
@@ -721,6 +728,8 @@  This program has absolutely no warranty.
 	  break;
 
 	case OPTION_DUMPCONFIG:
+	  if (verbose > 0)
+	    print_version_id ();
 	  fprintf (stderr, _("alias = %s\n"), TARGET_ALIAS);
 	  fprintf (stderr, _("canonical = %s\n"), TARGET_CANONICAL);
 	  fprintf (stderr, _("cpu-type = %s\n"), TARGET_CPU);
@@ -1130,6 +1139,9 @@  This program has absolutely no warranty.
 	}
     }
 
+  if (verbose > 0)
+    print_version_id ();
+
   free (shortopts);
   free (longopts);