[Driver] Select newest GCC installation on Solaris
authorRainer Orth <ro@gcc.gnu.org>
Wed, 16 Aug 2023 07:57:59 +0000 (09:57 +0200)
committerTobias Hieta <tobias@hieta.se>
Tue, 22 Aug 2023 05:43:58 +0000 (07:43 +0200)
commit53e5a6392ab4c37aff9438e96ba0f92d8321af51
tree9ff7467929726445779047f5f11279fe75081dcf
parentf1f9dd395b538c84bbc86958cc7de62faa847c71
[Driver] Select newest GCC installation on Solaris

As described in Issue #53709
<https://github.com/llvm/llvm-project/issues/53709>, since
28d58d8fe2094af6902dee7b4d68ec30a3e9d737
<https://reviews.llvm.org/rG28d58d8fe2094af6902dee7b4d68ec30a3e9d737>
`clang` doesn't find the latest of several parallel GCC installations on
Solaris, but only the first in directory order, which is pretty random.

This patch sorts GCC installations in reverse version order so the latest
is picked.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D157275

(cherry picked from commit ae84ad15efd7ef7da95146e900ec72ceadf98058)
clang/lib/Driver/ToolChains/Gnu.cpp
clang/unittests/Driver/ToolChainTest.cpp