From ab09e2dc3c315bfa1898061e64862ad9919bec77 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 1 Aug 2024 13:20:59 +0200 Subject: [PATCH] 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 --- src/plugins/projectexplorer/gcctoolchain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 2b9e05a1d72..d3a74b5fa50 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1453,6 +1453,8 @@ Toolchains GccToolchainFactory::autoDetect(const ToolchainDetector &detector) co executables.removeOne(FilePath::fromPathPart(u"/usr/bin/g++")); } + Utils::sort(executables); + const OsType os = detector.device->osType(); Toolchains result;