[DRIVER PATCH]: Nadger subprocess argv[0]

Joseph Myers joseph@codesourcery.com
Tue Nov 19 04:37:00 GMT 2019


On Tue, 14 May 2019, Nathan Sidwell wrote:

> This patch nadgers the driver's subprocess names to include the driver name.
> It results in more informative error messages.  For instance, rather than:
> 
>   >./xg++ -B./ frob.cc -c -fdump-tree-nope
>   cc1plus: error: unrecognized command line option '-fdump-tree-nope'
> 
> we get:
> 
>   >./xg++ -B./ frob.cc -c -fdump-tree-nope
>   xg++(cc1plus): error: unrecognized command line option '-fdump-tree-nope'
> 
> Thereby cluing the user into this being a compiler error.  (When this error is
> buried inside a build log, the poor user can be more confused as to what this
> cc1plus thing might be).

My inclination is that, whatever you do with argv[0], it's a bug for the 
message to mention cc1plus at all.  The fact that there is an executable 
called cc1plus is an implementation detail, which shouldn't be visible in 
diagnostics; the diagnostics should just mention the program the user 
called (e.g. g++) and not cc1plus.  (So make toplev.c use the value of 
COLLECT_GCC, if set, instead of argv[0], to determine the name for 
diagnostic purposes, I suppose.  I believe COLLECT_GCC should always be 
set except when cc1plus was called manually, and if it was called manually 
then it's reasonable to mention it in diagnostics and the person calling 
it is probably a GCC developer anyway.)

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list