From 3accdb8086cca78fc006cfbe0d8b6eb66ebcc307 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 Aug 2015 13:31:35 -0700 Subject: Detect which C++ standard edition the compiler defaults to Change-Id: I2991557a5cc74cd18e88ffff13f670bf25d5423e Reviewed-by: Kai Koehne --- tools/configure/configureapp.cpp | 24 ++++++++++++++++++++++-- tools/configure/configureapp.h | 3 ++- 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'tools/configure') diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index c4455eeb63..6a7a217446 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2343,6 +2343,22 @@ void Configure::autoDetection() dictionary["C++11"] = tryCompileProject("common/c++11") ? "yes" : "no"; } + if (!dictionary["QMAKESPEC"].contains("msvc")) { + if (tryCompileProject("common/c++default", QString(), false)) { + QFile iiFile(buildPath + "/config.tests/common/c++default/c++default.ii"); + if (iiFile.open(QIODevice::ReadOnly)) { + QString content = QString::fromUtf8(iiFile.readAll()); + QRegExp expr("\\b([0-9]+)L\\b"); + if (expr.indexIn(content) != -1) + dictionary["CFG_STDCXX_DEFAULT"] = expr.cap(1); + } + } + if (dictionary["CFG_STDCXX_DEFAULT"].isEmpty()) { + cout << "Could not determine the C++ standard the compiler uses by default, assuming C++98." << endl; + dictionary["CFG_STDCXX_DEFAULT"] = "199711"; + } + } + // Style detection if (dictionary["STYLE_WINDOWSXP"] == "auto") dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no"; @@ -2681,6 +2697,8 @@ void Configure::generateOutputVars() if (dictionary[ "C++11" ] == "yes") qtConfig += "c++11"; + if (!dictionary[ "CFG_STDCXX_DEFAULT" ].isEmpty()) + qmakeVars += "QT_COMPILER_STDCXX = " + dictionary[ "CFG_STDCXX_DEFAULT" ]; if (dictionary[ "USE_GOLD_LINKER" ] == "yes") qmakeConfig += "use_gold_linker"; @@ -3289,7 +3307,8 @@ void Configure::detectArch() QDir::setCurrent(oldpwd); } -bool Configure::tryCompileProject(const QString &projectPath, const QString &extraOptions) +bool Configure::tryCompileProject(const QString &projectPath, const QString &extraOptions, + bool distClean) { QString oldpwd = QDir::currentPath(); @@ -3332,7 +3351,8 @@ bool Configure::tryCompileProject(const QString &projectPath, const QString &ext //cout << output << endl; // clean up - Environment::execute(command + " distclean 2>&1"); + if (distClean) + Environment::execute(command + " distclean 2>&1"); } QDir::setCurrent(oldpwd); diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index e58a0feb2b..de8d1a2469 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -158,7 +158,8 @@ private: void saveCmdLine(); void addSysroot(QString *command); - bool tryCompileProject(const QString &projectPath, const QString &extraOptions = QString()); + bool tryCompileProject(const QString &projectPath, const QString &extraOptions = QString(), + bool distClean = true); bool compilerSupportsFlag(const QString &compilerAndArgs); void desc(const char *description, int startingAt = 0, int wrapIndent = 0); -- cgit v1.2.3 From 4684c1afe5fdb3774d56d85a52b2feaab1b8de2c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Jul 2015 17:21:30 -0700 Subject: Add detection of C++14 and C++1z compiler features [ChangeLog][General Improvements] Qt's buildsystem now detects whether the compiler supports C++14 and experimental support for C++1z. If the compiler supports it, then Qt is automatically compiled using that support. \ This does not apply to user applications built using qmake: those are still built with C++11 support only. To enable support for C++14 in your application, add to your .pro file: CONFIG += c++14 (similarly for C++1z). Change-Id: Ib056b47dde3341ef9a52ffff13ef1f5d01c42596 Reviewed-by: Lars Knoll --- tools/configure/configureapp.cpp | 66 ++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 20 deletions(-) (limited to 'tools/configure') diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 6a7a217446..ab4e091d6b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -238,7 +238,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "COMPILE_EXAMPLES" ] = "yes"; - dictionary[ "C++11" ] = "auto"; + dictionary[ "C++STD" ] = "auto"; dictionary[ "USE_GOLD_LINKER" ] = "no"; @@ -464,9 +464,29 @@ void Configure::parseCmdLine() } else if (configCmdLine.at(i) == "-c++11") - dictionary[ "C++11" ] = "yes"; + dictionary[ "C++STD" ] = "c++11"; else if (configCmdLine.at(i) == "-no-c++11") - dictionary[ "C++11" ] = "no"; + dictionary[ "C++STD" ] = "c++98"; + else if (configCmdLine.at(i) == "-c++std") { + ++i; + if (i == argCount) + break; + + QString level = configCmdLine.at(i); + if (level == "c++98" || level == "c++11" || level == "c++14" || level == "c++1z" + || level == "auto") { + dictionary[ "C++STD" ] = level; + } else if (level == "98" || level == "11" || level == "14" || level == "1z") { + dictionary[ "C++STD" ] = "c++" + level; + } else { + dictionary[ "DONE" ] = "error"; + cout << "ERROR: invalid C++ standard " << level + << "; valid options are: c++98 c++11 c++14 c++1z auto" << endl; + return; + } + } + + else if (configCmdLine.at(i) == "-use-gold-linker") dictionary[ "USE_GOLD_LINKER" ] = "yes"; else if (configCmdLine.at(i) == "-no-use-gold-linker") @@ -1791,8 +1811,8 @@ bool Configure::displayHelp() desc("OPENSOURCE", "opensource", "-opensource", "Compile and link the Open-Source Edition of Qt."); desc("COMMERCIAL", "commercial", "-commercial", "Compile and link the Commercial Edition of Qt.\n"); - desc("C++11", "yes", "-c++11", "Compile Qt with C++11 support enabled."); - desc("C++11", "no", "-no-c++11", "Do not compile Qt with C++11 support enabled.\n"); + desc( "-c++std ", "Compile Qt with C++ standard edition (c++98, c++11, c++14, c++1z)\n" + "Default: highest supported. This option is not supported for MSVC.\n"); desc("USE_GOLD_LINKER", "yes", "-use-gold-linker", "Link using the GNU gold linker (gcc only)."); desc("USE_GOLD_LINKER", "no", "-no-use-gold-linker", "Do not link using the GNU gold linker.\n"); @@ -2117,7 +2137,7 @@ QString Configure::defaultTo(const QString &option) return "no"; // keep 'auto' default for msvc, since we can't set the language supported - if (option == "C++11" + if (option == "C++STD" && dictionary["QMAKESPEC"].contains("msvc")) return "auto"; @@ -2338,9 +2358,16 @@ void Configure::autoDetection() // Auto-detect CPU architectures. detectArch(); - if (dictionary["C++11"] == "auto") { - if (!dictionary["QMAKESPEC"].contains("msvc")) - dictionary["C++11"] = tryCompileProject("common/c++11") ? "yes" : "no"; + if (dictionary["C++STD"] == "auto" && !dictionary["QMAKESPEC"].contains("msvc")) { + if (!tryCompileProject("common/c++11")) { + dictionary["C++STD"] = "c++98"; + } else if (!tryCompileProject("common/c++14")) { + dictionary["C++STD"] = "c++11"; + } else if (!tryCompileProject("common/c++1z")) { + dictionary["C++STD"] = "c++14"; + } else { + dictionary["C++STD"] = "c++1z"; + } } if (!dictionary["QMAKESPEC"].contains("msvc")) { @@ -2544,16 +2571,11 @@ void Configure::autoDetection() bool Configure::verifyConfiguration() { bool prompt = false; - if (dictionary["C++11"] != "auto" + if (dictionary["C++STD"] != "auto" && dictionary["QMAKESPEC"].contains("msvc")) { - cout << "WARNING: Qt does not support disabling or enabling any existing C++11 support " - "with MSVC compilers."; - if (dictionary["C++11"] == "yes") - cout << "Therefore -c++11 is ignored." << endl << endl; - else - cout << "Therefore -no-c++11 is ignored." << endl << endl; - - dictionary["C++11"] = "auto"; + cout << "WARNING: It is not possible to change the C++ standard edition with MSVC compilers. " + "Therefore, the option -c++std " << dictionary["C++STD"] << " was ignored." << endl << endl; + dictionary["C++STD"] = "auto"; } if (dictionary["STATIC_RUNTIME"] == "yes" && dictionary["SHARED"] == "yes") { @@ -2695,8 +2717,12 @@ void Configure::generateOutputVars() qtConfig += "release"; } - if (dictionary[ "C++11" ] == "yes") + if (dictionary[ "C++STD" ] == "c++11") qtConfig += "c++11"; + else if (dictionary[ "C++STD" ] == "c++14") + qtConfig += "c++11 c++14"; + else if (dictionary[ "C++STD" ] == "c++1z") + qtConfig += "c++11 c++14 c++1z"; if (!dictionary[ "CFG_STDCXX_DEFAULT" ].isEmpty()) qmakeVars += "QT_COMPILER_STDCXX = " + dictionary[ "CFG_STDCXX_DEFAULT" ]; @@ -3773,7 +3799,7 @@ void Configure::displayConfig() } if (dictionary[ "BUILD" ] == "release" || dictionary[ "BUILDALL" ] == "yes") sout << "Force debug info............" << dictionary[ "FORCEDEBUGINFO" ] << endl; - sout << "C++11 support..............." << dictionary[ "C++11" ] << endl; + sout << "C++ language standard......." << dictionary[ "C++STD" ] << endl; sout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl; sout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl; sout << "RTTI support................" << dictionary[ "RTTI" ] << endl; -- cgit v1.2.3 From b1738d63298ef1850995d13e9f7c8bcc6156edc1 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 2 Sep 2015 13:51:35 +0200 Subject: WinRT: Display error message when configuring with -no-opengl -no-opengl is not a supported option when compiling for WinRT or Windows Phone. Hence bail out early to avoid compilation errors at later stage. Task-number: QTBUG-48041 Change-Id: I449b8935b95f0b75139a0f7bfa13256ea3fe95e5 Reviewed-by: Andrew Knight Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools/configure') diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index ab4e091d6b..99cc69eb5f 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2677,6 +2677,14 @@ bool Configure::verifyConfiguration() } } + if (dictionary["OPENGL"] == "no" || dictionary["OPENGL_ES_2"] == "no") { + if (dictionary.value("XQMAKESPEC").startsWith("winphone") || + dictionary.value("XQMAKESPEC").startsWith("winrt")) { + cout << "ERROR: Option -no-opengl is not valid for WinRT." << endl; + dictionary[ "DONE" ] = "error"; + } + } + if (prompt) promptKeyPress(); -- cgit v1.2.3 From 3d7586b760550b7d89594c8d7462fc30b868ecc6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Sep 2015 20:35:33 -0300 Subject: Auto-detect whether 64-bit std::atomic really works The C++ standard says it must, but some badly-configured toolchains seem to be lacking support. In particular, for some 32-bit platforms without native support for them, GCC implements 64-bit atomics via out-of-line functions in libatomic. If that library is missing... well, then std::atomic 64-bit doesn't work and we mustn't try to use it. This was found when trying to compile Qt 5.6 for MIPS 32-bit: Linking library libQt5Core.so.5.6.0 .obj/qsimd.o: In function `std::__atomic_base::load(std::memory_order) const': /opt/poky/1.7/sysroots/mips32r2-poky-linux/usr/include/c++/4.9.1/bits/atomic_base.h:500: undefined reference to `__atomic_load_8' .obj/qsimd.o: In function `std::__atomic_base::store(unsigned long long, std::memory_order)': /opt/poky/1.7/sysroots/mips32r2-poky-linux/usr/include/c++/4.9.1/bits/atomic_base.h:478: undefined reference to `__atomic_store_8' Yocto bug report: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8274 Change-Id: I42e7ef1a481840699a8dffff140224d6614e5c36 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- tools/configure/configureapp.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tools/configure') diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 99cc69eb5f..f955a8de2e 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2014 Intel Corporation +** Copyright (C) 2015 Intel Corporation ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the tools applications of the Qt Toolkit. @@ -192,6 +192,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "SYSTEM_PROXIES" ] = "no"; dictionary[ "WERROR" ] = "auto"; dictionary[ "QREAL" ] = "double"; + dictionary[ "ATOMIC64" ] = "auto"; //Only used when cross compiling. dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg"; @@ -2215,6 +2216,12 @@ bool Configure::checkAvailability(const QString &part) else if (part == "OBJCOPY") available = tryCompileProject("unix/objcopy"); + else if (part == "ATOMIC64") + available = tryCompileProject("common/atomic64"); + + else if (part == "ATOMIC64-LIBATOMIC") + available = tryCompileProject("common/atomic64", "LIBS+=-latomic"); + else if (part == "ZLIB") available = findFile("zlib.h"); @@ -2386,6 +2393,10 @@ void Configure::autoDetection() } } + if (dictionary["ATOMIC64"] == "auto") + dictionary["ATOMIC64"] = checkAvailability("ATOMIC64") ? "yes" : + checkAvailability("ATOMIC64-LIBATOMIC") ? "libatomic" : "no"; + // Style detection if (dictionary["STYLE_WINDOWSXP"] == "auto") dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no"; @@ -2917,6 +2928,9 @@ void Configure::generateOutputVars() } } + if (dictionary["ATOMIC64"] == "libatomic") + qmakeConfig += "atomic64-libatomic"; + if (dictionary[ "ACCESSIBILITY" ] == "yes") qtConfig += "accessibility"; @@ -3720,6 +3734,7 @@ void Configure::generateConfigfiles() if (dictionary["QT_GLIB"] == "no") qconfigList += "QT_NO_GLIB"; if (dictionary["QT_INOTIFY"] == "no") qconfigList += "QT_NO_INOTIFY"; if (dictionary["QT_EVENTFD"] == "no") qconfigList += "QT_NO_EVENTFD"; + if (dictionary["ATOMIC64"] == "no") qconfigList += "QT_NO_STD_ATOMIC64"; if (dictionary["REDUCE_EXPORTS"] == "yes") qconfigList += "QT_VISIBILITY_AVAILABLE"; if (dictionary["REDUCE_RELOCATIONS"] == "yes") qconfigList += "QT_REDUCE_RELOCATIONS"; -- cgit v1.2.3