From 3a671c2bb9e4b9a7b86903687b7869d298f3bcba Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 13 Oct 2023 09:35:31 +0200 Subject: [PATCH] ProjectExplorer: Fix autodetect of toolchains on macOS ...when not loading the iOS plugin. Fixes a condition and lowers priority of gcc/g++ on macOS in general. Without this patch Qt related kits had a detected g++/gcc assigned as compiler which made the kits useless. When loading the iOS plugin the Apple related clang is preferred which made the issue not present by default. Fixes execution of AutoTest and ClangTools plugin unit tests too. Change-Id: I7515980c0fda48c942d7f3e7cb4d8c66965a1ab3 Reviewed-by: hjk Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/gcctoolchain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index e43022f403b..78b5ba4737a 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1364,7 +1364,7 @@ Toolchains GccToolChainFactory::autoDetect(const ToolchainDetector &detector) co }, {nameFilters, QDir::Files | QDir::Executable }); // Gcc is almost never what you want on macOS, but it is by default found in /usr/bin - if (HostOsInfo::isMacHost() && detector.device->type() != Constants::DESKTOP_DEVICE_TYPE) { + if (HostOsInfo::isMacHost() && detector.device->type() == Constants::DESKTOP_DEVICE_TYPE) { executables.removeOne(FilePath::fromPathPart(u"/usr/bin/gcc")); executables.removeOne(FilePath::fromPathPart(u"/usr/bin/g++")); } @@ -1575,6 +1575,9 @@ Toolchains GccToolChainFactory::autoDetectToolChain(const ToolChainDescription & tc->setTargetAbi(abi); tc->setOriginalTargetTriple(detectedAbis.originalTargetTriple); tc->setDisplayName(tc->defaultDisplayName()); // reset displayname + // lower priority of g++/gcc on macOS - usually just a frontend to clang + if (detectedSubType == GccToolChain::RealGcc && abi.binaryFormat() == Abi::MachOFormat) + tc->setPriority(ToolChain::PriorityLow); result.append(tc); } return result;