[PATCH 1/2] gas: Improve file name in messages header

Jan Beulich jbeulich@suse.com
Thu Aug 14 06:07:37 GMT 2025


On 13.08.2025 20:02, Alice Carlotti wrote:
> Message output from gas is prefixed with a line of the form:
> 
> path/file.s: Assembler messages:
> 
> Don't use the file name from the first message for this header.
> Instead, use the source file name specified in the command line.
> 
> Ok for master?

A few small concerns:

> --- a/gas/messages.c
> +++ b/gas/messages.c
> @@ -27,7 +27,6 @@
>  extern const char *strsignal (int);
>  #endif
>  
> -static void identify (const char *);
>  static void as_show_where (void);
>  static void as_warn_internal (const char *, unsigned int, char *);
>  static void as_bad_internal (const char *, unsigned int, char *);
> @@ -72,8 +71,16 @@ static void signal_crash (int) ATTRIBUTE_NORETURN;
>     as_abort () is used for logic failure (assert or abort, signal).
>  */
>  
> +static const char *ident_name;
> +
> +void
> +message_name (const char *name)

I consider the function name too generic for its purpose. Seeing that ...

> @@ -81,14 +88,8 @@ identify (const char *file)

... this is the only user, maybe identify_name()?

>      return;
>    identified++;
>  
> -  if (!file)
> -    {
> -      unsigned int x;
> -      file = as_where (&x);
> -    }
> -
> -  if (file)
> -    fprintf (stderr, "%s: ", file);
> +  if (ident_name)

read_a_source_file() is called with "", not NULL, when there's no file name
input argument.

> --- a/gas/read.c
> +++ b/gas/read.c
> @@ -897,6 +897,7 @@ read_a_source_file (const char *name)
>  
>    buffer = input_scrub_new_file (name);
>  
> +  message_name (name);

Shouldn't this move ahead of input_scrub_new_file()?

Also, what if there's no diagnostic at all for the first file, but there is
one for a later input? It may be intentional to then show that file's name,
but that's not given. An option might be to not show a file name at all in
identify().

Jan


More information about the Binutils mailing list