diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp
index 8e5e8675f88f8c9623d2c5f5764ddcd0e4b0b53c..d593b8718c37739b529ec21848555a4046e77a0f 100644
--- a/src/plugins/projectexplorer/gcctoolchain.cpp
+++ b/src/plugins/projectexplorer/gcctoolchain.cpp
@@ -412,10 +412,14 @@ QString GccToolChain::mkspec() const
         return QLatin1String("macx-g++");
     }
 
-    Abi gccAbi = Abi::abisOfBinary(m_compilerPath);
-    if (gccAbi.architecture() != abi.architecture()
-            || gccAbi.os() != abi.os()
-            || gccAbi.osFlavor() != abi.osFlavor()) {
+    QList<Abi> gccAbiList = Abi::abisOfBinary(m_compilerPath);
+    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 QString(); // this is a cross-compiler, leave the mkspec alone!
     }