gnu/gcc.git/a514707ffd7d58b140686036c2dece43ecb7d33c [PATCH v6 4/4] find_a_program: Search with machine prefix in some cases
Prefatory note:
I've since learned that this quite similar to
https://inbox.sourceware.org/gcc-patches/20240522095404.1825269-1-syq@gcc.gnu.org/,
postdating my original patch series, but predating this version. See
that thread for additional motivation. That patch updated a few specific
callsite for various programs; I instead opted to enhance find_a_program
(which I myself originally factored out of find_a_file in
5fee8a0a9223d030c66d53c104fb0a431369248f for this purpose) to catch all
such cases programmatically.
Behavior Change:
Today, GCC will search for:
1. path/$machine/$version/prog
2. path/$machine/prog
3. path/prog
This means, we might search for:
1. path/$machine/$version/prog
2. path/$machine/prog
3. path/$machine-prog # new
4. path/prog
But it will not search for:
- path/$machine/$version/$machine-prog
- path/$machine/$machine-prog
I want this change because when cross compiling, users expect prefixed
tools, like
- $AS = $machine-as
- $LD = $machine-ld
etc. and it would be less confusing if GCC would find those same tools
in a similar way. GCC instead looking for its own (less widely used than
prefixing) nested-directory way of disambiguating, and then falling back
looking for *unprefixed* tools (which typically are for the wrong
platform in cross cases) is quite confusing. In my distro, Nixpkgs, and
elsewhere, I've seen people draw the wrong conclusions because of this,
which is that one must use absolute paths hard-coded at build time in
order to get the right behavior, and dodge the incorrect unprefixed
tools.
For what its worth, Clang/LLVM also look for prefixed tools in this
manner, so this isn't the first time it would be done. The difference is
that they will look for prefixed tools in *all* cases --- i.e. also
within the machine-specific locations as I outlined above (as things
this patch does *not* do). I think that was done for mere coding
convenience, and there is no actual motivation "doubly disambiguating"
tools with machine directories and machine prefixes. So in the interest
of sticking strictly to the motivation / being conservative in how much
new behavior is implemented, I did not implement that part.
gcc/ChangeLog:
* gcc.cc (find_a_program): Implement the new behavior described
above.
(driver::set_up_specs): Initilize variable. It would be nice to
have less spooky-action-at-a-distince using C++ features, but I
just matched how the corresponding suffix variable worked for
now for uniformity.
Signed-off-by: John Ericson <git@JohnEricson.me>
1 file changed