ProjectExplorer: Sort initial list of toolchain executables

This makes things more deterministic and ensures we consistently prefer
the version-less variant from a set of file paths pointing to the same
compiler executable.
Example on my machine:
  /usr/bin/aarch64-linux-gnu-gcc
  /usr/bin/aarch64-linux-gnu-gcc-14.1.0
  /usr/bin/aarch64-linux-gnu-++ (no versioned variant present!)
Before this patch, QtC preferred /usr/bin/aarch64-linux-gnu-gcc-14.1.0
to /usr/bin/aarch64-linux-gnu-gcc, because it was found first when
iterating the directory, and then discarded /usr/bin/aarch64-linux-gnu-
gcc as a duplicate, which resulted in an ugly asymmetry between the C
and C++ toolchains.

Fixes: QTCREATORBUG-31132
Change-Id: I2da252beda1b565e66906f10fa1e8a9d36ad852c
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2024-08-01 13:20:59 +02:00
parent d83b2a80d3
commit ab09e2dc3c

View File

@@ -1453,6 +1453,8 @@ Toolchains GccToolchainFactory::autoDetect(const ToolchainDetector &detector) co
executables.removeOne(FilePath::fromPathPart(u"/usr/bin/g++")); executables.removeOne(FilePath::fromPathPart(u"/usr/bin/g++"));
} }
Utils::sort(executables);
const OsType os = detector.device->osType(); const OsType os = detector.device->osType();
Toolchains result; Toolchains result;