From 3afd3a37d30f6ca46054812a3e142eb9d683cccc Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Thu, 2 Feb 2012 11:56:09 +0100
Subject: [PATCH] Mac: Do not override mkspec when cross-compiling

Change-Id: I6fc17a80f99002a99c1218f3fea18e52c2aad40d
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
---
 src/plugins/projectexplorer/gcctoolchain.cpp | 23 ++++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp
index 9503a62fb09..b9a156632af 100644
--- a/src/plugins/projectexplorer/gcctoolchain.cpp
+++ b/src/plugins/projectexplorer/gcctoolchain.cpp
@@ -414,6 +414,14 @@ Utils::FileName GccToolChain::debuggerCommand() const
 Utils::FileName GccToolChain::mkspec() const
 {
     Abi abi = targetAbi();
+    Abi host = Abi::hostAbi();
+
+    // Cross compile: Leave the mkspec alone!
+    if (abi.architecture() != host.architecture()
+            || abi.os() != host.os()
+            || abi.osFlavor() != host.osFlavor()) // Note: This can fail:-(
+        return Utils::FileName();
+
     if (abi.os() == Abi::MacOS) {
         QString v = version();
         // prefer versioned g++ on mac. This is required to enable building for older Mac OS versions
@@ -424,26 +432,17 @@ Utils::FileName GccToolChain::mkspec() const
         return Utils::FileName::fromString(QLatin1String("macx-g++"));
     }
 
-    QList<Abi> gccAbiList = Abi::abisOfBinary(m_compilerCommand);
-    Abi gccAbi;
-    if (!gccAbiList.isEmpty())
-        gccAbi  = gccAbiList.first();
-    if (!gccAbi.isNull()
-            && (gccAbi.architecture() != abi.architecture()
-                || gccAbi.os() != abi.os()
-                || gccAbi.osFlavor() != abi.osFlavor())) {
-        // Note: This can fail:-(
-        return Utils::FileName(); // this is a cross-compiler, leave the mkspec alone!
-    }
     if (abi.os() == Abi::LinuxOS) {
         if (abi.osFlavor() != Abi::GenericLinuxFlavor)
             return Utils::FileName(); // most likely not a desktop, so leave the mkspec alone.
-        if (abi.wordWidth() == gccAbi.wordWidth())
+        if (abi.wordWidth() == host.wordWidth())
             return Utils::FileName::fromString(QLatin1String("linux-g++")); // no need to explicitly set the word width
         return Utils::FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
     }
+
     if (abi.os() == Abi::BsdOS && abi.osFlavor() == Abi::FreeBsdFlavor)
         return Utils::FileName::fromString(QLatin1String("freebsd-g++"));
+
     return Utils::FileName();
 }
 
-- 
GitLab