ProjectPart: save codegen flags in project part

And add them to other clang code model arguments.
These flags provide architecture for cross-compilation
when ios kit is selected.

Task-number: QTCREATORBUG-19437
Task-number: QTCREATORBUG-19430
Change-Id: I7a485f49d637371bb28b2096086d7d8a4b0c404a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ivan Donchevskii
2017-12-15 15:28:13 +01:00
parent 8c4dcda6d4
commit e51683412b
9 changed files with 25 additions and 3 deletions

View File

@@ -52,6 +52,7 @@ QStringList CompilerOptionsBuilder::build(CppTools::ProjectFile::Kind fileKind,
addWordWidth(); addWordWidth();
addTargetTriple(); addTargetTriple();
addExtraCodeModelFlags();
addLanguageOption(fileKind); addLanguageOption(fileKind);
addOptionsForLanguage(/*checkForBorlandExtensions*/ true); addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
enableExceptions(); enableExceptions();
@@ -104,6 +105,14 @@ void CompilerOptionsBuilder::addTargetTriple()
} }
} }
void CompilerOptionsBuilder::addExtraCodeModelFlags()
{
// extraCodeModelFlags keep build architecture for cross-compilation.
// In case of iOS build target triple has aarch64 archtecture set which makes
// code model fail with CXError_Failure. To fix that we explicitly provide architecture.
m_options.append(m_projectPart.extraCodeModelFlags);
}
void CompilerOptionsBuilder::enableExceptions() void CompilerOptionsBuilder::enableExceptions()
{ {
add(QLatin1String("-fcxx-exceptions")); add(QLatin1String("-fcxx-exceptions"));

View File

@@ -45,6 +45,7 @@ public:
virtual ~CompilerOptionsBuilder() {} virtual ~CompilerOptionsBuilder() {}
virtual void addTargetTriple(); virtual void addTargetTriple();
virtual void addExtraCodeModelFlags();
virtual void enableExceptions(); virtual void enableExceptions();
virtual void addPredefinedHeaderPathsOptions(); virtual void addPredefinedHeaderPathsOptions();
virtual void addLanguageOption(ProjectFile::Kind fileKind); virtual void addLanguageOption(ProjectFile::Kind fileKind);

View File

@@ -52,6 +52,7 @@ public:
m_projectPart.isMsvc2015Toolchain = m_tcInfo.isMsvc2015ToolChain; m_projectPart.isMsvc2015Toolchain = m_tcInfo.isMsvc2015ToolChain;
m_projectPart.toolChainWordWidth = mapWordWith(m_tcInfo.wordWidth); m_projectPart.toolChainWordWidth = mapWordWith(m_tcInfo.wordWidth);
m_projectPart.toolChainTargetTriple = m_tcInfo.targetTriple; m_projectPart.toolChainTargetTriple = m_tcInfo.targetTriple;
m_projectPart.extraCodeModelFlags = m_tcInfo.extraCodeModelFlags;
m_projectPart.warningFlags = m_flags.warningFlags; m_projectPart.warningFlags = m_flags.warningFlags;
@@ -128,7 +129,7 @@ private:
const QList<ProjectExplorer::HeaderPath> systemHeaderPaths const QList<ProjectExplorer::HeaderPath> systemHeaderPaths
= m_tcInfo.headerPathsRunner(m_flags.commandLineFlags, = m_tcInfo.headerPathsRunner(m_flags.commandLineFlags,
m_tcInfo.sysRoothPath); m_tcInfo.sysRootPath);
ProjectPartHeaderPaths &headerPaths = m_projectPart.headerPaths; ProjectPartHeaderPaths &headerPaths = m_projectPart.headerPaths;
for (const ProjectExplorer::HeaderPath &header : systemHeaderPaths) { for (const ProjectExplorer::HeaderPath &header : systemHeaderPaths) {

View File

@@ -26,6 +26,7 @@
#include "projectinfo.h" #include "projectinfo.h"
#include <projectexplorer/abi.h> #include <projectexplorer/abi.h>
#include <projectexplorer/gcctoolchain.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -41,10 +42,11 @@ ToolChainInfo::ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
= toolChain->targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMsvc2015Flavor; = toolChain->targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMsvc2015Flavor;
wordWidth = toolChain->targetAbi().wordWidth(); wordWidth = toolChain->targetAbi().wordWidth();
targetTriple = toolChain->originalTargetTriple(); targetTriple = toolChain->originalTargetTriple();
extraCodeModelFlags = toolChain->extraCodeModelFlags();
// ...and save the potentially expensive operations for later so that // ...and save the potentially expensive operations for later so that
// they can be run from a worker thread. // they can be run from a worker thread.
sysRoothPath = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString(); sysRootPath = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString();
headerPathsRunner = toolChain->createSystemHeaderPathsRunner(); headerPathsRunner = toolChain->createSystemHeaderPathsRunner();
predefinedMacrosRunner = toolChain->createPredefinedMacrosRunner(); predefinedMacrosRunner = toolChain->createPredefinedMacrosRunner();
} }

View File

@@ -54,8 +54,9 @@ public:
bool isMsvc2015ToolChain = false; bool isMsvc2015ToolChain = false;
unsigned wordWidth = 0; unsigned wordWidth = 0;
QString targetTriple; QString targetTriple;
QStringList extraCodeModelFlags;
QString sysRoothPath; // For headerPathsRunner. QString sysRootPath; // For headerPathsRunner.
ProjectExplorer::ToolChain::SystemHeaderPathsRunner headerPathsRunner; ProjectExplorer::ToolChain::SystemHeaderPathsRunner headerPathsRunner;
ProjectExplorer::ToolChain::PredefinedMacrosRunner predefinedMacrosRunner; ProjectExplorer::ToolChain::PredefinedMacrosRunner predefinedMacrosRunner;
}; };

View File

@@ -140,6 +140,7 @@ public:
ProjectExplorer::Macros toolChainMacros; ProjectExplorer::Macros toolChainMacros;
ToolChainWordWidth toolChainWordWidth = WordWidth32Bit; ToolChainWordWidth toolChainWordWidth = WordWidth32Bit;
QString toolChainTargetTriple; QString toolChainTargetTriple;
QStringList extraCodeModelFlags;
BuildTargetType buildTargetType = Unknown; BuildTargetType buildTargetType = Unknown;
}; };

View File

@@ -774,6 +774,11 @@ void GccToolChain::setPlatformCodeGenFlags(const QStringList &flags)
} }
} }
QStringList GccToolChain::extraCodeModelFlags() const
{
return platformCodeGenFlags();
}
/*! /*!
Code gen flags that have to be passed to the compiler. Code gen flags that have to be passed to the compiler.
*/ */

View File

@@ -165,6 +165,7 @@ public:
void resetToolChain(const Utils::FileName &); void resetToolChain(const Utils::FileName &);
Utils::FileName compilerCommand() const override; Utils::FileName compilerCommand() const override;
void setPlatformCodeGenFlags(const QStringList &); void setPlatformCodeGenFlags(const QStringList &);
QStringList extraCodeModelFlags() const override;
QStringList platformCodeGenFlags() const; QStringList platformCodeGenFlags() const;
void setPlatformLinkerFlags(const QStringList &); void setPlatformLinkerFlags(const QStringList &);
QStringList platformLinkerFlags() const; QStringList platformLinkerFlags() const;

View File

@@ -100,6 +100,7 @@ public:
virtual Abi targetAbi() const = 0; virtual Abi targetAbi() const = 0;
virtual QList<Abi> supportedAbis() const; virtual QList<Abi> supportedAbis() const;
virtual QString originalTargetTriple() const { return QString(); } virtual QString originalTargetTriple() const { return QString(); }
virtual QStringList extraCodeModelFlags() const { return QStringList(); }
virtual bool isValid() const = 0; virtual bool isValid() const = 0;