From e50c9afce996d5fdc6298819ba289d0e63d4342c Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 10 Nov 2016 23:20:44 -0800 Subject: [PATCH] Qbs: filter out -arch compiler flags from platformCompiler/LinkerFlags -arch is not allowed in compiler flags as it's automatically handled by the qbs.architecture property, and is an error in current versions of Qbs. If the architecture was successfully detected, remove the flags. Change-Id: I85cce7b7f4ef5a92f857ec624a912861bcb267f5 Reviewed-by: Eike Ziller Reviewed-by: Christian Kandeler --- .../defaultpropertyprovider.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index 0d8796e9262..ba24c94fb9f 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -171,6 +171,20 @@ static MSVCVersion msvcCompilerVersion(const ProjectExplorer::Abi &abi) return v; } +static void filterCompilerLinkerFlags(const ProjectExplorer::Abi &targetAbi, QStringList &flags) +{ + for (int i = 0; i < flags.size(); ) { + if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture + && flags[i] == QStringLiteral("-arch") + && i + 1 < flags.size()) { + flags.removeAt(i); + flags.removeAt(i); + } else { + ++i; + } + } +} + QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplorer::Kit *k, const QVariantMap &defaultData) const { @@ -234,8 +248,13 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor data.insert(QLatin1String(CPP_TOOLCHAINPATH), cxxFileInfo.absolutePath()); if (ProjectExplorer::GccToolChain *gcc = dynamic_cast(tc)) { - data.insert(QLatin1String(CPP_PLATFORMCOMMONCOMPILERFLAGS), gcc->platformCodeGenFlags()); - data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), gcc->platformLinkerFlags()); + QStringList compilerFlags = gcc->platformCodeGenFlags(); + filterCompilerLinkerFlags(targetAbi, compilerFlags); + data.insert(QLatin1String(CPP_PLATFORMCOMMONCOMPILERFLAGS), compilerFlags); + + QStringList linkerFlags = gcc->platformLinkerFlags(); + filterCompilerLinkerFlags(targetAbi, linkerFlags); + data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), linkerFlags); } if (targetAbi.os() == ProjectExplorer::Abi::MacOS) {