forked from qt-creator/qt-creator
ProjectExplorer: Do not set up x64 compilers as x86 toolchains by default
That blows up the toolchain list on Unix systems, and is usually not what users want. Those who do can opt in. Fixes: QTCREATORBUG-20044 Change-Id: I6a4ef26ff5f0aaddc660cccf59283c6e8c4bdb64 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -203,8 +203,10 @@ static QList<Abi> guessGccAbi(const QString &m, const ProjectExplorer::Macros &m
|
||||
abiList << Abi(arch, os, flavor, format, width == 64 ? 32 : 64);
|
||||
} else if (arch == Abi::X86Architecture && (width == 0 || width == 64)) {
|
||||
abiList << Abi(arch, os, flavor, format, 64);
|
||||
if (width != 64 || !m.contains("mingw"))
|
||||
if (width != 64 || (!m.contains("mingw")
|
||||
&& ToolChainManager::detectionSettings().detectX64AsX32)) {
|
||||
abiList << Abi(arch, os, flavor, format, 32);
|
||||
}
|
||||
} else {
|
||||
abiList << Abi(arch, os, flavor, format, width);
|
||||
}
|
||||
@@ -1885,7 +1887,7 @@ void ProjectExplorerPlugin::testGccAbiGuessing_data()
|
||||
QTest::newRow("Linux 3 (64bit intel)")
|
||||
<< QString::fromLatin1("x86_64-linux-gnu")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
||||
<< QStringList({"x86-linux-generic-elf-64bit", "x86-linux-generic-elf-32bit"});
|
||||
<< QStringList("x86-linux-generic-elf-64bit");
|
||||
QTest::newRow("Linux 3 (64bit intel -- non 64bit)")
|
||||
<< QString::fromLatin1("x86_64-linux-gnu")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
||||
@@ -1897,11 +1899,11 @@ void ProjectExplorerPlugin::testGccAbiGuessing_data()
|
||||
QTest::newRow("Linux 5 (QTCREATORBUG-4690)") // from QTCREATORBUG-4690
|
||||
<< QString::fromLatin1("x86_64-redhat-linux6E")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
||||
<< QStringList({"x86-linux-generic-elf-64bit", "x86-linux-generic-elf-32bit"});
|
||||
<< QStringList("x86-linux-generic-elf-64bit");
|
||||
QTest::newRow("Linux 6 (QTCREATORBUG-4690)") // from QTCREATORBUG-4690
|
||||
<< QString::fromLatin1("x86_64-redhat-linux")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
||||
<< QStringList({"x86-linux-generic-elf-64bit", "x86-linux-generic-elf-32bit"});
|
||||
<< QStringList("x86-linux-generic-elf-64bit");
|
||||
QTest::newRow("Linux 7 (arm)")
|
||||
<< QString::fromLatin1("armv5tl-montavista-linux-gnueabi")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
||||
@@ -1946,11 +1948,11 @@ void ProjectExplorerPlugin::testGccAbiGuessing_data()
|
||||
QTest::newRow("Clang 1: windows")
|
||||
<< QString::fromLatin1("x86_64-pc-win32")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
|
||||
<< QStringList({"x86-windows-msys-pe-64bit", "x86-windows-msys-pe-32bit"});
|
||||
<< QStringList("x86-windows-msys-pe-64bit");
|
||||
QTest::newRow("Clang 1: linux")
|
||||
<< QString::fromLatin1("x86_64-unknown-linux-gnu")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
||||
<< QStringList({"x86-linux-generic-elf-64bit", "x86-linux-generic-elf-32bit"});
|
||||
<< QStringList("x86-linux-generic-elf-64bit");
|
||||
QTest::newRow("Mac 1")
|
||||
<< QString::fromLatin1("i686-apple-darwin10")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
||||
@@ -1970,7 +1972,7 @@ void ProjectExplorerPlugin::testGccAbiGuessing_data()
|
||||
QTest::newRow("Intel 1")
|
||||
<< QString::fromLatin1("86_64 x86_64 GNU/Linux")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
|
||||
<< QStringList({"x86-linux-generic-elf-64bit", "x86-linux-generic-elf-32bit"});
|
||||
<< QStringList("x86-linux-generic-elf-64bit");
|
||||
QTest::newRow("FreeBSD 1")
|
||||
<< QString::fromLatin1("i386-portbld-freebsd9.0")
|
||||
<< QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
|
||||
|
@@ -68,6 +68,7 @@ public:
|
||||
|
||||
QList<ToolChain *> m_toolChains; // prioritized List
|
||||
QVector<LanguageDisplayPair> m_languages;
|
||||
ToolchainDetectionSettings m_detectionSettings;
|
||||
};
|
||||
|
||||
ToolChainManagerPrivate::~ToolChainManagerPrivate()
|
||||
@@ -83,6 +84,8 @@ static ToolChainManagerPrivate *d = nullptr;
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
const char DETECT_X64_AS_X32_KEY[] = "ProjectExplorer/Toolchains/DetectX64AsX32";
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ToolChainManager
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -100,6 +103,9 @@ ToolChainManager::ToolChainManager(QObject *parent) :
|
||||
connect(this, &ToolChainManager::toolChainAdded, this, &ToolChainManager::toolChainsChanged);
|
||||
connect(this, &ToolChainManager::toolChainRemoved, this, &ToolChainManager::toolChainsChanged);
|
||||
connect(this, &ToolChainManager::toolChainUpdated, this, &ToolChainManager::toolChainsChanged);
|
||||
|
||||
QSettings * const s = Core::ICore::settings();
|
||||
d->m_detectionSettings.detectX64AsX32 = s->value(DETECT_X64_AS_X32_KEY, false).toBool();
|
||||
}
|
||||
|
||||
ToolChainManager::~ToolChainManager()
|
||||
@@ -130,6 +136,8 @@ void ToolChainManager::saveToolChains()
|
||||
QTC_ASSERT(d->m_accessor, return);
|
||||
|
||||
d->m_accessor->saveToolChains(d->m_toolChains, Core::ICore::dialogParent());
|
||||
QSettings * const s = Core::ICore::settings();
|
||||
s->setValue(DETECT_X64_AS_X32_KEY, d->m_detectionSettings.detectX64AsX32);
|
||||
}
|
||||
|
||||
QList<ToolChain *> ToolChainManager::toolChains(const ToolChain::Predicate &predicate)
|
||||
@@ -257,4 +265,14 @@ void ToolChainManager::aboutToShutdown()
|
||||
#endif
|
||||
}
|
||||
|
||||
ToolchainDetectionSettings ToolChainManager::detectionSettings()
|
||||
{
|
||||
return d->m_detectionSettings;
|
||||
}
|
||||
|
||||
void ToolChainManager::setDetectionSettings(const ToolchainDetectionSettings &settings)
|
||||
{
|
||||
d->m_detectionSettings = settings;
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -45,6 +45,12 @@ namespace ProjectExplorer {
|
||||
class ProjectExplorerPlugin;
|
||||
class Abi;
|
||||
|
||||
class ToolchainDetectionSettings
|
||||
{
|
||||
public:
|
||||
bool detectX64AsX32 = false;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ToolChainManager
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -76,6 +82,9 @@ public:
|
||||
|
||||
static void aboutToShutdown();
|
||||
|
||||
static ToolchainDetectionSettings detectionSettings();
|
||||
static void setDetectionSettings(const ToolchainDetectionSettings &settings);
|
||||
|
||||
void saveToolChains();
|
||||
|
||||
signals:
|
||||
|
@@ -42,6 +42,9 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QItemSelectionModel>
|
||||
@@ -108,6 +111,39 @@ public:
|
||||
bool changed;
|
||||
};
|
||||
|
||||
class DetectionSettingsDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
DetectionSettingsDialog(const ToolchainDetectionSettings &settings, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setWindowTitle(ToolChainOptionsPage::tr("TGoolchain Auto-detection Settings"));
|
||||
const auto layout = new QVBoxLayout(this);
|
||||
m_detectX64AsX32CheckBox.setText(ToolChainOptionsPage::tr("Detect x86_64 GCC compilers "
|
||||
"as x86_64 and x86"));
|
||||
m_detectX64AsX32CheckBox.setToolTip(ToolChainOptionsPage::tr("If checked, Qt Creator will "
|
||||
"set up two instances of each x86_64 compiler:\nOne for the native x86_64 target, "
|
||||
"and one for a plain x86 target.\nEnable this if you plan to create 32-bit x86 "
|
||||
"binaries without using a dedicated cross compiler."));
|
||||
m_detectX64AsX32CheckBox.setChecked(settings.detectX64AsX32);
|
||||
layout->addWidget(&m_detectX64AsX32CheckBox);
|
||||
const auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
layout->addWidget(buttonBox);
|
||||
}
|
||||
|
||||
ToolchainDetectionSettings settings() const
|
||||
{
|
||||
ToolchainDetectionSettings s;
|
||||
s.detectX64AsX32 = m_detectX64AsX32CheckBox.isChecked();
|
||||
return s;
|
||||
}
|
||||
|
||||
private:
|
||||
QCheckBox m_detectX64AsX32CheckBox;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ToolChainOptionsWidget
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -117,6 +153,7 @@ class ToolChainOptionsWidget : public QWidget
|
||||
public:
|
||||
ToolChainOptionsWidget()
|
||||
{
|
||||
m_detectionSettings = ToolChainManager::detectionSettings();
|
||||
m_factories = Utils::filtered(ToolChainFactory::allToolChainFactories(),
|
||||
[](ToolChainFactory *factory) { return factory->canCreate();});
|
||||
|
||||
@@ -173,6 +210,15 @@ public:
|
||||
|
||||
m_delButton = new QPushButton(ToolChainOptionsPage::tr("Remove"), this);
|
||||
|
||||
m_detectionSettingsButton = new QPushButton(
|
||||
ToolChainOptionsPage::tr("Auto-detection Settings..."), this);
|
||||
connect(m_detectionSettingsButton, &QAbstractButton::clicked, this,
|
||||
[this] {
|
||||
DetectionSettingsDialog dlg(m_detectionSettings, this);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
m_detectionSettings = dlg.settings();
|
||||
});
|
||||
|
||||
m_container = new DetailsWidget(this);
|
||||
m_container->setState(DetailsWidget::NoSummary);
|
||||
m_container->setVisible(false);
|
||||
@@ -189,6 +235,7 @@ public:
|
||||
buttonLayout->addWidget(m_addButton);
|
||||
buttonLayout->addWidget(m_cloneButton);
|
||||
buttonLayout->addWidget(m_delButton);
|
||||
buttonLayout->addWidget(m_detectionSettingsButton);
|
||||
buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
|
||||
auto verticalLayout = new QVBoxLayout;
|
||||
@@ -238,7 +285,7 @@ public:
|
||||
|
||||
void apply();
|
||||
|
||||
public:
|
||||
private:
|
||||
TreeModel<TreeItem, ToolChainTreeItem> m_model;
|
||||
QList<ToolChainFactory *> m_factories;
|
||||
QTreeView *m_toolChainView;
|
||||
@@ -247,11 +294,14 @@ public:
|
||||
QPushButton *m_addButton;
|
||||
QPushButton *m_cloneButton;
|
||||
QPushButton *m_delButton;
|
||||
QPushButton *m_detectionSettingsButton;
|
||||
|
||||
QHash<Core::Id, QPair<StaticTreeItem *, StaticTreeItem *>> m_languageMap;
|
||||
|
||||
QList<ToolChainTreeItem *> m_toAddList;
|
||||
QList<ToolChainTreeItem *> m_toRemoveList;
|
||||
|
||||
ToolchainDetectionSettings m_detectionSettings;
|
||||
};
|
||||
|
||||
void ToolChainOptionsWidget::markForRemoval(ToolChainTreeItem *item)
|
||||
@@ -378,6 +428,7 @@ void ToolChainOptionsWidget::apply()
|
||||
"They were not configured again.")
|
||||
.arg(removedTcs.join(QLatin1String(",<br> "))));
|
||||
}
|
||||
ToolChainManager::setDetectionSettings(m_detectionSettings);
|
||||
}
|
||||
|
||||
void ToolChainOptionsWidget::createToolChain(ToolChainFactory *factory, const Core::Id &language)
|
||||
|
Reference in New Issue
Block a user