[clang][Driver] Correct tool search path priority
authorDavid Spickett <david.spickett@linaro.org>
Mon, 11 May 2020 16:13:00 +0000 (17:13 +0100)
committerDavid Spickett <david.spickett@linaro.org>
Mon, 22 Jun 2020 08:41:13 +0000 (09:41 +0100)
commit028571d60843cb87e2637ef69ee09090d4526c62
treea86df0bde3c28ad5bf4a39018f4dc554ecff9826
parent4bcd08eb1c3bcd6ce580cc21b4e6d9f10286b9e6
[clang][Driver] Correct tool search path priority

Summary:
As seen in:
https://bugs.llvm.org/show_bug.cgi?id=45693

When clang looks for a tool it has a set of
possible names for it, in priority order.
Previously it would look for these names in
the program path. Then look for all the names
in the PATH.

This means that aarch64-none-elf-gcc on the PATH
would lose to gcc in the program path.
(which was /usr/bin in the bug's case)

This changes that logic to search each name in both
possible locations, then move to the next name.
Which is more what you would expect to happen when
using a non default triple.

(-B prefixes maybe should follow this logic too,
but are not changed in this patch)

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79988
clang/lib/Driver/Driver.cpp
clang/test/Driver/program-path-priority.c [new file with mode: 0644]
clang/test/lit.cfg.py