From d8bf317546bcfab0b6b50375218429fa9d470705 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 1 Oct 2013 12:34:20 +0200 Subject: make qreal double by default on all platforms On modern ARM CPUs there is no speed difference between float and double anymore, so let's rather use double for qreal to avoid rounding and precision issues. Like this we also get much better compatibility with our desktop OSes. This is not binary compatible on ARM, but the old behavior can be restored by passing -qreal float to configure. Change-Id: I2a4b61e19a3dfa6b0bd76734cecf2634c97207fc Reviewed-by: Thiago Macieira --- configure | 16 ++++++++++++++++ dist/changes-5.2.0 | 11 +++++++++++ src/corelib/global/qglobal.h | 3 --- tools/configure/configureapp.cpp | 12 ++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/configure b/configure index b5e375baed..4adaa77403 100755 --- a/configure +++ b/configure @@ -1006,6 +1006,7 @@ QPA_PLATFORM_GUARD=yes CFG_CXX11=auto CFG_DIRECTWRITE=no CFG_WERROR=auto +CFG_QREAL=double OPT_MAC_SDK= # initalize variables used for installation @@ -1168,6 +1169,7 @@ while [ "$#" -gt 0 ]; do -mysql_config| \ -qpa| \ -qconfig| \ + -qreal| \ -android-sdk| \ -android-ndk| \ -android-ndk-platform| \ @@ -1419,6 +1421,9 @@ while [ "$#" -gt 0 ]; do qconfig) CFG_QCONFIG="$VAL" ;; + qreal) + CFG_QREAL="$VAL" + ;; sysroot) CFG_SYSROOT="$VAL" ;; @@ -3699,6 +3704,9 @@ Additional options: -qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the default ($CFG_QCONFIG). + -qreal [double|float] typedef qreal to the specified type. The default is double. + Note that changing this flag affects binary compatibility. + -no-opengl .......... Do not support OpenGL. -opengl ....... Enable OpenGL support With no parameter, this will attempt to auto-detect @@ -6356,6 +6364,10 @@ if [ "$CFG_LARGEFILE" = "yes" ] && [ "$XPLATFORM_MINGW" != "yes" ]; then echo "#define QT_LARGEFILE_SUPPORT 64" >>"$outpath/src/corelib/global/qconfig.h.new" fi +if [ "$CFG_QREAL" != double ]; then + echo "#define QT_COORD_TYPE $CFG_QREAL" >>"$outpath/src/corelib/global/qconfig.h.new" +fi + if [ "$CFG_FRAMEWORK" = "yes" ]; then echo "#define QT_MAC_FRAMEWORK_BUILD" >>"$outpath/src/corelib/global/qconfig.h.new" fi @@ -6960,6 +6972,10 @@ if [ "$ORIG_CFG_XKBCOMMON" != qt ] && [ "$CFG_XKBCOMMON" = qt ]; then echo "NOTE: libxkbcommon 0.2.0 (or higher) not found on the system, will use " echo "the bundled version from 3rd party directory." fi +if [ "$CFG_QREAL" = double ] && [ "$CFG_ARCH" = arm ]; then + echo "NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1." + echo "Configure with '-qreal float' to create a build that is binary compatible with 5.1." +fi exec 1>&3 3>&- # restore stdout cat $outpath/config.summary # display config feedback to user diff --git a/dist/changes-5.2.0 b/dist/changes-5.2.0 index 1eda87b553..c0db0f28f9 100644 --- a/dist/changes-5.2.0 +++ b/dist/changes-5.2.0 @@ -15,10 +15,21 @@ corresponding to tasks in the Qt Bug Tracker: Each of these identifiers can be entered in the bug tracker to obtain more information about a particular change. +**************************************************************************** +* Architecture Specific Changes * +**************************************************************************** + +Qt is now compiled with qreal typedef'ed to double on all platforms. qreal +was a float on ARM chipsets before. This guarantees more consistent behavior +between all platforms Qt supports, but is binary incompatible to Qt 5.1 +on ARM. The old behavior can be restored by passing -qreal float to +configure. + **************************************************************************** * Library * **************************************************************************** + QtWidgets --------- diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 0fd9bab979..5bb675728a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -213,11 +213,8 @@ typedef unsigned int uint; typedef unsigned long ulong; QT_END_INCLUDE_NAMESPACE -// This logic must match the one in qmetatype.h #if defined(QT_COORD_TYPE) typedef QT_COORD_TYPE qreal; -#elif defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE) -typedef float qreal; #else typedef double qreal; #endif diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 5d4ce84941..4c323a3540 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -196,6 +196,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "SLOG2" ] = "no"; dictionary[ "SYSTEM_PROXIES" ] = "no"; dictionary[ "WERROR" ] = "auto"; + dictionary[ "QREAL" ] = "double"; //Only used when cross compiling. dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg"; @@ -418,6 +419,12 @@ void Configure::parseCmdLine() break; dictionary[ "QCONFIG" ] = configCmdLine.at(i); } + else if (configCmdLine.at(i) == "-qreal") { + ++i; + if (i == argCount) + break; + dictionary[ "QREAL" ] = configCmdLine.at(i); + } else if (configCmdLine.at(i) == "-release") { dictionary[ "BUILD" ] = "release"; @@ -1876,6 +1883,9 @@ bool Configure::displayHelp() desc("PROCESS", "full", "-fully-process", "Generate Makefiles/Project files for the entire Qt\ntree."); desc("PROCESS", "no", "-dont-process", "Do not generate Makefiles/Project files.\n"); + desc( "-qreal [double|float]", "typedef qreal to the specified type. The default is double.\n" + "Note that changing this flag affects binary compatibility.\n"); + desc("RTTI", "no", "-no-rtti", "Do not compile runtime type information."); desc("RTTI", "yes", "-rtti", "Compile runtime type information."); desc("STRIP", "no", "-no-strip", "Do not strip libraries and executables of debug info when installing."); @@ -3298,6 +3308,8 @@ void Configure::generateConfigfiles() if (dictionary[ "NEON" ] == "yes") tmpStream << "#define QT_COMPILER_SUPPORTS_NEON" << endl; + if (dictionary["QREAL"] != "double") + tmpStream << "#define QT_COORD_TYPE " << dictionary["QREAL"] << endl; tmpStream << endl << "// Compile time features" << endl; -- cgit v1.2.3