Commit b2df065b authored by Tobias Hunger's avatar Tobias Hunger

Use distinct ABIs for MSVC versions

Use a distinct ABI OS flavor for each of the supported MSVC versions.

Task-number: QTCREATORBUG-4129
parent 6b8eb847
......@@ -409,7 +409,9 @@ void CMakeRunPage::initializePage()
ProjectExplorer::Abi targetAbi = tc->targetAbi();
QVariant tcVariant = qVariantFromValue(static_cast<void *>(tc));
if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvcFlavor)
if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor)
m_generatorComboBox->addItem(tr("NMake Generator (%1)").arg(tc->displayName()), tcVariant);
else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor)
m_generatorComboBox->addItem(tr("MinGW Generator (%1)").arg(tc->displayName()), tcVariant);
......@@ -450,10 +452,10 @@ void CMakeRunPage::runCMake()
QString generator = QLatin1String("-GCodeBlocks - Unix Makefiles");
if (tc->targetAbi().os() == ProjectExplorer::Abi::WindowsOS) {
if (tc->targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMsvcFlavor)
generator = QLatin1String("-GCodeBlocks - NMake Makefiles");
else
if (tc->targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor)
generator = QLatin1String("-GCodeBlocks - MinGW Makefiles");
else
generator = QLatin1String("-GCodeBlocks - NMake Makefiles");
}
......
......@@ -349,7 +349,9 @@ static QString cdbBinary(const DebuggerStartParameters &sp)
if (!sp.debuggerCommand.isEmpty()) {
// Do not use a GDB binary if we got started for a project with MinGW runtime.
const bool abiMatch = sp.toolChainAbi.os() == ProjectExplorer::Abi::WindowsOS
&& sp.toolChainAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvcFlavor;
&& (sp.toolChainAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
|| sp.toolChainAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
|| sp.toolChainAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor);
if (abiMatch)
return sp.debuggerCommand;
}
......
......@@ -1474,7 +1474,7 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
Abi hostAbi = Abi::hostAbi();
sp.toolChainAbi = ProjectExplorer::Abi(hostAbi.architecture(),
ProjectExplorer::Abi::WindowsOS,
ProjectExplorer::Abi::WindowsMsvcFlavor,
ProjectExplorer::Abi::WindowsMsvc2010Flavor,
ProjectExplorer::Abi::PEFormat,
true);
sp.startMode = AttachToRemote;
......@@ -2461,7 +2461,7 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType
if (searchAbi.os() == ProjectExplorer::Abi::WindowsOS) {
switch (et) {
case CdbEngineType:
searchAbi = Abi(abi.architecture(), abi.os(), Abi::WindowsMsvcFlavor,
searchAbi = Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2010Flavor,
abi.binaryFormat(), abi.wordWidth());
break;
case GdbEngineType:
......
......@@ -93,10 +93,24 @@ static QList<Abi> parseCoffHeader(const QByteArray &data)
if (data.size() >= 68) {
// Get Major and Minor Image Version from optional header fields
quint32 image = (data.at(67) << 24) + (data.at(66) << 16) + (data.at(65) << 8) + data.at(64);
if (image == 1) // Image is 1 for mingw and higher for MSVC (4.something in some encoding)
if (image == 1) { // Image is 1 for mingw and higher for MSVC (4.something in some encoding)
flavor = Abi::WindowsMSysFlavor;
else
flavor = Abi::WindowsMsvcFlavor;
} else {
switch (data.at(22)) {
case 8:
flavor = Abi::WindowsMsvc2005Flavor;
break;
case 9:
flavor = Abi::WindowsMsvc2008Flavor;
break;
case 10:
flavor = Abi::WindowsMsvc2010Flavor;
break;
default:
// Keep unknown flavor
break;
}
}
}
if (arch != Abi::UnknownArchitecture && width != 0)
......@@ -196,7 +210,7 @@ Abi::Abi(const Architecture &a, const OS &o,
m_osFlavor = UnknownFlavor;
break;
case ProjectExplorer::Abi::WindowsOS:
if (m_osFlavor < WindowsMsvcFlavor || m_osFlavor > WindowsCEFlavor)
if (m_osFlavor < WindowsMsvc2005Flavor || m_osFlavor > WindowsCEFlavor)
m_osFlavor = UnknownFlavor;
break;
}
......@@ -258,8 +272,12 @@ Abi::Abi(const QString &abiString) :
m_osFlavor = SymbianEmulatorFlavor;
else if (abiParts.at(2) == QLatin1String("generic") && m_os == UnixOS)
m_osFlavor = GenericUnixFlavor;
else if (abiParts.at(2) == QLatin1String("msvc") && m_os == WindowsOS)
m_osFlavor = WindowsMsvcFlavor;
else if (abiParts.at(2) == QLatin1String("msvc2005") && m_os == WindowsOS)
m_osFlavor = WindowsMsvc2005Flavor;
else if (abiParts.at(2) == QLatin1String("msvc2008") && m_os == WindowsOS)
m_osFlavor = WindowsMsvc2008Flavor;
else if (abiParts.at(2) == QLatin1String("msvc2010") && m_os == WindowsOS)
m_osFlavor = WindowsMsvc2010Flavor;
else if (abiParts.at(2) == QLatin1String("msys") && m_os == WindowsOS)
m_osFlavor = WindowsMSysFlavor;
else if (abiParts.at(2) == QLatin1String("ce") && m_os == WindowsOS)
......@@ -399,8 +417,12 @@ QString Abi::toString(const OSFlavor &of)
return QLatin1String("emulator");
case ProjectExplorer::Abi::GenericUnixFlavor:
return QLatin1String("generic");
case ProjectExplorer::Abi::WindowsMsvcFlavor:
return QLatin1String("msvc");
case ProjectExplorer::Abi::WindowsMsvc2005Flavor:
return QLatin1String("msvc2005");
case ProjectExplorer::Abi::WindowsMsvc2008Flavor:
return QLatin1String("msvc2008");
case ProjectExplorer::Abi::WindowsMsvc2010Flavor:
return QLatin1String("msvc2010");
case ProjectExplorer::Abi::WindowsMSysFlavor:
return QLatin1String("msys");
case ProjectExplorer::Abi::WindowsCEFlavor:
......@@ -445,7 +467,15 @@ Abi Abi::hostAbi()
#if defined (Q_OS_WIN)
os = WindowsOS;
subos = WindowsMsvcFlavor;
#if _MSC_VER == 1600
subos = WindowsMsvc2010Flavor;
#elif _MSC_VER == 1500
subos = WindowsMsvc2008Flavor;
#elif _MSC_VER == 1400
subos = WindowsMsvc2005Flavor;
#elif defined (mingw32)
subos = WindowsMSysFlavor;
#endif
format = PEFormat;
#elif defined (Q_OS_LINUX)
os = LinuxOS;
......
......@@ -85,7 +85,9 @@ public:
GenericUnixFlavor,
// Windows
WindowsMsvcFlavor,
WindowsMsvc2005Flavor,
WindowsMsvc2008Flavor,
WindowsMsvc2010Flavor,
WindowsMSysFlavor,
WindowsCEFlavor
};
......
......@@ -82,6 +82,44 @@ static QString platformName(MsvcToolChain::Platform t)
return QString();
}
static Abi findAbiOfMsvc(MsvcToolChain::Type type, MsvcToolChain::Platform platform, const QString &version)
{
Abi::Architecture arch = Abi::X86Architecture;
Abi::OSFlavor flavor = Abi::UnknownFlavor;
int wordWidth = 64;
switch (platform)
{
case ProjectExplorer::Internal::MsvcToolChain::s32:
wordWidth = 32;
break;
case ProjectExplorer::Internal::MsvcToolChain::ia64:
arch = Abi::ItaniumArchitecture;
break;
case ProjectExplorer::Internal::MsvcToolChain::s64:
case ProjectExplorer::Internal::MsvcToolChain::amd64:
break;
};
QString msvcVersionString = version;
if (type == MsvcToolChain::WindowsSDK) {
if (version.startsWith("7."))
msvcVersionString = "10.0";
else if (version.startsWith("6.1"))
msvcVersionString = "9.0";
else
msvcVersionString = "8.0";
}
if (msvcVersionString.startsWith("10."))
flavor = Abi::WindowsMsvc2010Flavor;
else if (msvcVersionString.startsWith("9."))
flavor = Abi::WindowsMsvc2008Flavor;
else
flavor = Abi::WindowsMsvc2005Flavor;
return Abi(arch, Abi::WindowsOS, flavor, Abi::PEFormat, wordWidth);
}
static QString generateDisplayName(const QString &name,
MsvcToolChain::Type t,
MsvcToolChain::Platform p)
......@@ -309,36 +347,25 @@ static Utils::Environment msvcReadEnvironmentSetting(const QString &varsBat,
// MsvcToolChain
// --------------------------------------------------------------------------
MsvcToolChain::MsvcToolChain(Type type, const QString &name, Platform platform,
MsvcToolChain::MsvcToolChain(const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg, bool autodetect) :
ToolChain(QLatin1String(Constants::MSVC_TOOLCHAIN_ID), autodetect),
m_varsBat(varsBat),
m_varsBatArg(varsBatArg),
m_lastEnvironment(Utils::Environment::systemEnvironment()),
m_is64bit(true),
m_architecture(Abi::X86Architecture)
m_abi(abi)
{
Q_ASSERT(!name.isEmpty());
Q_ASSERT(!m_varsBat.isEmpty());
Q_ASSERT(QFileInfo(m_varsBat).exists());
switch (platform)
{
case ProjectExplorer::Internal::MsvcToolChain::s32:
m_is64bit = false;
break;
case ProjectExplorer::Internal::MsvcToolChain::ia64:
m_architecture = Abi::ItaniumArchitecture;
break;
case ProjectExplorer::Internal::MsvcToolChain::s64:
case ProjectExplorer::Internal::MsvcToolChain::amd64:
break;
};
Q_ASSERT(abi.os() == Abi::WindowsOS);
Q_ASSERT(abi.binaryFormat() == Abi::PEFormat);
Q_ASSERT(abi.osFlavor() != Abi::WindowsMSysFlavor);
setId(QString::fromLatin1("%1:%2.%3").arg(Constants::MSVC_TOOLCHAIN_ID).arg(m_varsBat)
.arg(m_varsBatArg));
setDisplayName(generateDisplayName(name, type, platform));
setDisplayName(name);
}
QString MsvcToolChain::typeName() const
......@@ -348,7 +375,7 @@ QString MsvcToolChain::typeName() const
Abi MsvcToolChain::targetAbi() const
{
return Abi(m_architecture, Abi::WindowsOS, Abi::WindowsMsvcFlavor, Abi::PEFormat, m_is64bit ? 64 : 32);
return m_abi;
}
bool MsvcToolChain::isValid() const
......@@ -566,6 +593,7 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect()
if (!defaultSdkPath.isEmpty()) {
foreach (const QString &sdkKey, sdkRegistry.childGroups()) {
const QString name = sdkRegistry.value(sdkKey + QLatin1String("/ProductName")).toString();
const QString version = sdkRegistry.value(sdkKey + QLatin1String("/ProductVersion")).toString();
const QString folder = sdkRegistry.value(sdkKey + QLatin1String("/InstallationFolder")).toString();
if (folder.isEmpty())
continue;
......@@ -574,13 +602,17 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect()
if (!QFileInfo(sdkVcVarsBat).exists())
continue;
QList<ToolChain *> tmp;
tmp.append(new MsvcToolChain(MsvcToolChain::WindowsSDK, name,MsvcToolChain::s32,
tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::s32),
findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::s32, version),
sdkVcVarsBat, QLatin1String("/x86"), true));
#ifdef Q_OS_WIN64
// Add all platforms
tmp.append(new MsvcToolChain(MsvcToolChain::WindowsSDK, name, MsvcToolChain::s64,
tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::s64),
findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::s64, version),
sdkVcVarsBat, QLatin1String("/x64"), true));
tmp.append(new MsvcToolChain(MsvcToolChain::WindowsSDK, name, MsvcToolChain::ia64,
tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::ia64),
findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::ia64, version),
sdkVcVarsBat, QLatin1String("/ia64"), true));
#endif
// Make sure the default is front.
......@@ -610,19 +642,24 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect()
// Check existence of various install scripts
const QString vcvars32bat = path + QLatin1String("bin\\vcvars32.bat");
if (QFileInfo(vcvars32bat).isFile())
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::s32,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::s32),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::s32, vsName),
vcvars32bat, QString(), true));
if (version >= 10) {
// Just one common file
const QString vcvarsAllbat = path + QLatin1String("vcvarsall.bat");
if (QFileInfo(vcvarsAllbat).isFile()) {
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::s32,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::s32),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::s32, vsName),
vcvarsAllbat, QLatin1String("x86"), true));
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::amd64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::amd64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::amd64, vsName),
vcvarsAllbat, QLatin1String("amd64"), true));
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::s64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::s64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::s64, vsName),
vcvarsAllbat, QLatin1String("x64"), true));
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::ia64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::ia64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::ia64, vsName),
vcvarsAllbat, QLatin1String("ia64"), true));
} else {
qWarning("Unable to find MSVC setup script %s in version %d", qPrintable(vcvarsAllbat), version);
......@@ -631,19 +668,23 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect()
// Amd 64 is the preferred 64bit platform
const QString vcvarsAmd64bat = path + QLatin1String("bin\\amd64\\vcvarsamd64.bat");
if (QFileInfo(vcvarsAmd64bat).isFile())
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::amd64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::amd64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::amd64, vsName),
vcvarsAmd64bat, QString(), true));
const QString vcvarsAmd64bat2 = path + QLatin1String("bin\\vcvarsx86_amd64.bat");
if (QFileInfo(vcvarsAmd64bat2).isFile())
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::amd64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::amd64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::amd64, vsName),
vcvarsAmd64bat2, QString(), true));
const QString vcvars64bat = path + QLatin1String("bin\\vcvars64.bat");
if (QFileInfo(vcvars64bat).isFile())
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::s64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::s64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::s64, vsName),
vcvars64bat, QString(), true));
const QString vcvarsIA64bat = path + QLatin1String("bin\\vcvarsx86_ia64.bat");
if (QFileInfo(vcvarsIA64bat).isFile())
results.append(new MsvcToolChain(MsvcToolChain::VS, vsName, MsvcToolChain::ia64,
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::ia64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::ia64, vsName),
vcvarsIA64bat, QString(), true));
}
}
......
......@@ -55,8 +55,8 @@ public:
enum Type { WindowsSDK, VS };
enum Platform { s32, s64, ia64, amd64 };
MsvcToolChain(Type type, const QString &name, Platform platform, const QString &varsBat,
const QString &varsBatArg, bool autodetect = false);
MsvcToolChain(const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg, bool autodetect = false);
QString typeName() const;
Abi targetAbi() const;
......@@ -89,8 +89,7 @@ private:
mutable Utils::Environment m_lastEnvironment; // Last checked 'incoming' environment.
mutable Utils::Environment m_resultEnvironment; // Resulting environment for VC
mutable QList<HeaderPath> m_headerPaths;
bool m_is64bit;
Abi::Architecture m_architecture;
Abi m_abi;
};
// --------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment