On 5/14/19 8:02 AM, 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).
I achieve this by taking advantage of the subprocess spawning taking
separate arguments for the program to exec, and the argv[0] value passed
to that program. Because subprocesses can use argv[0] to locate
themselves I propagate the directory name, so that remains as before.
When using valgrind, this substitution is not performed, because
valgrind relies on argv[0] being the program pathname.
The -v output is unaffected, as that is emitted before altering argv[0].
argv[0] is also restored after spawning.
This then allows us to elide process_command's check of whether the
input file exists. That's optimizing for failure, but I suspect is
desired merely to avoid an error of the form:
cc1plus: fatal error: frob.cc: No such file or directory
As you can see process_command does some special handling for lto &
@files, which is kind of icky and now goes away. We get:
xg++(cc1plus): fatal error: frob.cc: No such file or directory
Thoughts? Ok? Stupid idea?
It sounds like a nice little improvement to me.
The question of what's cc1 and cc1plus sometimes comes up on
message boards indicating that users new to GCC find these
errors at first confusing. A common one is about:
gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory”
This one prints gcc but what's cc1plus and what's execvp? After
an incomplete install, newbie users go looking for cc1plus (and
sometimes apparently even for excecvp). Improving these messages
will make GCC easier for newbies to use.
Just a nit about the output above: is no space after the driver
name and before the parenthesis. To my eyes that looks a little
odd. I would expect see one.
Martin