On Sun, 19 Sep 2021, Jeff Law via Gcc-patches wrote: > On 8/4/2021 12:21 PM, John Ericson wrote: >> The helper is for `--print-prog-name` and similar things. Since all >> executable finding goes through it, we can move the default overrides >> into that path too. This also ensures that if some is looking for a >> *non*-program that called `as`, `ld`, etc., weird things don't happen. >> --- >> gcc/gcc.c | 59 ++++++++++++++++++++++++++++++++----------------------- >> 1 file changed, 34 insertions(+), 25 deletions(-) > Thanks. I added a ChangeLog entry and pushed this to the trunk.
| commit 5fee8a0a9223d030c66d53c104fb0a431369248f | Author: John Ericson <g...@johnericson.me> | Date: Sun Sep 19 11:08:32 2021 -0400 | | [PATCH] Factor out `find_a_program` helper around `find_a_file` | | gcc/ | * gcc.c (find_a_program): New function, factored out of... | (find_a_file): Here. | (execute): Use find_a_program when looking for programs rather | than find_a_file. I'm afraid this broke x86_64-unknown-freebsd12*: .../GCC-HEAD/gcc/gcc.c: In function 'char* find_a_program(const char*)': /scratch/tmp/gerald/GCC-HEAD/gcc/gcc.c:3086:59: error: 'mode' was not declared in this scope; did you mean 'pmode'? 3086 | if (! strcmp (name, "as") && access (DEFAULT_ASSEMBLER, mode) == 0) | ^~~~ | pmode /scratch/tmp/gerald/GCC-HEAD/gcc/gcc.c:3091:56: error: 'mode' was not declared in this scope; did you mean 'pmode'? 3091 | if (! strcmp (name, "ld") && access (DEFAULT_LINKER, mode) == 0) | ^~~~ | pmode Looking at the code in question I see static char* find_a_program (const char *name) { /* Do not search if default matches query. */ #ifdef DEFAULT_ASSEMBLER if (! strcmp (name, "as") && access (DEFAULT_ASSEMBLER, mode) == 0) return xstrdup (DEFAULT_ASSEMBLER); #endif where mode is not defined in that function. Looks like the factoring out did not take the non-default case into consideration? I was just going to commit a fix I tested last night, when that patch simply "disappeared". Looks like Ian beat me to it with exactly the same patch. :-) Gerald