summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-11-16 08:53:38 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-11-16 13:31:29 (GMT)
commitd4150975af620e2889cc58bd476bac6b4d101db3 (patch)
tree15e000be38cc530e25f68066ade6581d14a4f60d
parent2326a8d878e0d18473c27ddd54880621518b6e6e (diff)
downloadQt-d4150975af620e2889cc58bd476bac6b4d101db3.zip
Qt-d4150975af620e2889cc58bd476bac6b4d101db3.tar.gz
Qt-d4150975af620e2889cc58bd476bac6b4d101db3.tar.bz2
Windows: Add gcc 4.6.
- Add gcc 4.6 mkspec for > 4.4 (win32-g++-4.6) - Add detection of g++ version and 64bit to configure. Reviewed-by: mariusSO
-rw-r--r--mkspecs/win32-g++-4.6/qmake.conf3
-rw-r--r--mkspecs/win32-g++-4.6/qplatformdefs.h159
-rw-r--r--qmake/Makefile.win32-g++2
-rw-r--r--src/corelib/tools/qlocale_tools.cpp7
-rw-r--r--tools/configure/configureapp.cpp31
-rw-r--r--tools/configure/environment.cpp86
-rw-r--r--tools/configure/environment.h3
7 files changed, 275 insertions, 16 deletions
diff --git a/mkspecs/win32-g++-4.6/qmake.conf b/mkspecs/win32-g++-4.6/qmake.conf
new file mode 100644
index 0000000..2c94587
--- /dev/null
+++ b/mkspecs/win32-g++-4.6/qmake.conf
@@ -0,0 +1,3 @@
+include(../win32-g++/qmake.conf)
+QMAKE_CFLAGS *= -fno-keep-inline-dllexport
+QMAKE_CXXFLAGS *= -fno-keep-inline-dllexport
diff --git a/mkspecs/win32-g++-4.6/qplatformdefs.h b/mkspecs/win32-g++-4.6/qplatformdefs.h
new file mode 100644
index 0000000..630a6a4
--- /dev/null
+++ b/mkspecs/win32-g++-4.6/qplatformdefs.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake spec of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+#ifdef UNICODE
+#ifndef _UNICODE
+#define _UNICODE
+#endif
+#endif
+
+// Get Qt defines/settings
+
+#include "qglobal.h"
+
+#include <tchar.h>
+#include <io.h>
+#include <direct.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <qt_windows.h>
+#include <limits.h>
+
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT-0 < 0x0500)
+typedef enum {
+ NameUnknown = 0,
+ NameFullyQualifiedDN = 1,
+ NameSamCompatible = 2,
+ NameDisplay = 3,
+ NameUniqueId = 6,
+ NameCanonical = 7,
+ NameUserPrincipal = 8,
+ NameCanonicalEx = 9,
+ NameServicePrincipal = 10,
+ NameDnsDomain = 12
+} EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT;
+#endif
+
+#define Q_FS_FAT
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_STATBUF struct _stati64 // non-ANSI defs
+#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs
+#define QT_STAT ::_stati64
+#define QT_FSTAT ::_fstati64
+#else
+#define QT_STATBUF struct _stat // non-ANSI defs
+#define QT_STATBUF4TSTAT struct _stat // non-ANSI defs
+#define QT_STAT ::_stat
+#define QT_FSTAT ::_fstat
+#endif
+#define QT_STAT_REG _S_IFREG
+#define QT_STAT_DIR _S_IFDIR
+#define QT_STAT_MASK _S_IFMT
+#if defined(_S_IFLNK)
+# define QT_STAT_LNK _S_IFLNK
+#endif
+#define QT_FILENO _fileno
+#define QT_OPEN ::_open
+#define QT_CLOSE ::_close
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_LSEEK ::_lseeki64
+#ifndef UNICODE
+#define QT_TSTAT ::_stati64
+#else
+#define QT_TSTAT ::_wstati64
+#endif
+#else
+#define QT_LSEEK ::_lseek
+#ifndef UNICODE
+#define QT_TSTAT ::_stat
+#else
+#define QT_TSTAT ::_wstat
+#endif
+#endif
+#define QT_READ ::_read
+#define QT_WRITE ::_write
+#define QT_ACCESS ::_access
+#define QT_GETCWD ::_getcwd
+#define QT_CHDIR ::_chdir
+#define QT_MKDIR ::_mkdir
+#define QT_RMDIR ::_rmdir
+#define QT_OPEN_LARGEFILE 0
+#define QT_OPEN_RDONLY _O_RDONLY
+#define QT_OPEN_WRONLY _O_WRONLY
+#define QT_OPEN_RDWR _O_RDWR
+#define QT_OPEN_CREAT _O_CREAT
+#define QT_OPEN_TRUNC _O_TRUNC
+#define QT_OPEN_APPEND _O_APPEND
+#if defined(O_TEXT)
+# define QT_OPEN_TEXT _O_TEXT
+# define QT_OPEN_BINARY _O_BINARY
+#endif
+
+#include "../common/c89/qplatformdefs.h"
+
+#ifdef QT_LARGEFILE_SUPPORT
+#undef QT_FSEEK
+#undef QT_FTELL
+#undef QT_OFF_T
+
+#define QT_FSEEK ::fseeko64
+#define QT_FTELL ::ftello64
+#define QT_OFF_T off64_t
+#endif
+
+#define QT_SIGNAL_ARGS int
+
+#define QT_VSNPRINTF ::_vsnprintf
+#define QT_SNPRINTF ::_snprintf
+
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
+
+
+#endif // QPLATFORMDEFS_H
diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++
index d40dc29..5fa1e5e 100644
--- a/qmake/Makefile.win32-g++
+++ b/qmake/Makefile.win32-g++
@@ -27,7 +27,7 @@ CFLAGS = -c -o$@ -O \
-DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
-DQT_BOOTSTRAPPED -DQLIBRARYINFO_EPOCROOT
CXXFLAGS = $(CFLAGS)
-LFLAGS = -static-libgcc -static-libstdc++ -s
+LFLAGS = -static-libgcc -s
LIBS = -lole32 -luuid -ladvapi32 -lkernel32
LINKQMAKE = g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS)
ADDCLEAN =
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
index df31bf9..750379c 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/tools/qlocale_tools.cpp
@@ -2253,6 +2253,13 @@ static int quorem(Bigint *b, Bigint *S)
* calculation.
*/
+#if defined(Q_OS_WIN) && defined (Q_CC_GNU) && !defined(_clear87) // See QTBUG-7576
+extern "C" {
+__attribute__ ((dllimport)) unsigned int __cdecl __MINGW_NOTHROW _control87 (unsigned int unNew, unsigned int unMask);
+__attribute__ ((dllimport)) unsigned int __cdecl __MINGW_NOTHROW _clearfp (void); /* Clear the FPU status word */
+}
+# define _clear87 _clearfp
+#endif
/* This actually sometimes returns a pointer to a string literal
cast to a char*. Do NOT try to modify the return value. */
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index e6d8526..60996e3 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1263,17 +1263,18 @@ void Configure::parseCmdLine()
}
cout << "See the README file for a list of supported operating systems and compilers." << endl;
} else {
- if (dictionary[ "QMAKESPEC" ].endsWith("-icc") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc.net") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc2002") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc2003") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc2005") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc2008") ||
- dictionary[ "QMAKESPEC" ].endsWith("-msvc2010")) {
+ const QString qmakeSpec = dictionary[ "QMAKESPEC" ];
+ if (qmakeSpec.endsWith("-icc") ||
+ qmakeSpec.endsWith("-msvc") ||
+ qmakeSpec.endsWith("-msvc.net") ||
+ qmakeSpec.endsWith("-msvc2002") ||
+ qmakeSpec.endsWith("-msvc2003") ||
+ qmakeSpec.endsWith("-msvc2005") ||
+ qmakeSpec.endsWith("-msvc2008") ||
+ qmakeSpec.endsWith("-msvc2010")) {
if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
- } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
+ } else if (qmakeSpec.contains("win32-g++")) {
if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make";
if (Environment::detectExecutable("sh.exe")) {
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++-sh";
@@ -1329,7 +1330,7 @@ void Configure::parseCmdLine()
}
}
- useUnixSeparators = (dictionary["QMAKESPEC"] == "win32-g++");
+ useUnixSeparators = dictionary["QMAKESPEC"].contains("win32-g++");
// Allow tests for private classes to be compiled against internal builds
if (dictionary["BUILDDEV"] == "yes")
@@ -2201,7 +2202,9 @@ bool Configure::checkAvailability(const QString &part)
} else if (part == "MULTIMEDIA" || part == "SCRIPT" || part == "SCRIPTTOOLS" || part == "DECLARATIVE") {
available = true;
} else if (part == "WEBKIT") {
- available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-msvc2010") || (dictionary.value("QMAKESPEC") == "win32-g++");
+ const QString qmakeSpec = dictionary.value("QMAKESPEC");
+ available = qmakeSpec == "win32-msvc2005" || qmakeSpec == "win32-msvc2008" ||
+ qmakeSpec == "win32-msvc2010" || qmakeSpec.startsWith("win32-g++");
if (dictionary[ "SHARED" ] == "no") {
cout << endl << "WARNING: Using static linking will disable the WebKit module." << endl
<< endl;
@@ -2376,7 +2379,7 @@ bool Configure::verifyConfiguration()
dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue
}
- if (dictionary["QMAKESPEC"].endsWith("-g++")
+ if (dictionary["QMAKESPEC"].contains("-g++")
&& dictionary["SQL_OCI"] != "no") {
cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl
<< "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl
@@ -2456,7 +2459,7 @@ void Configure::generateBuildKey()
QString spec = dictionary["QMAKESPEC"];
QString compiler = "msvc"; // ICC is compatible
- if (spec.endsWith("-g++"))
+ if (spec.contains("-g++"))
compiler = "mingw";
else if (spec.endsWith("-borland"))
compiler = "borland";
@@ -2874,7 +2877,7 @@ void Configure::generateOutputVars()
if (!qmakeStylePlugins.isEmpty())
qmakeVars += QString("style-plugins += ") + qmakeStylePlugins.join(" ");
- if (dictionary["QMAKESPEC"].endsWith("-g++")) {
+ if (dictionary["QMAKESPEC"].contains("-g++")) {
QString includepath = qgetenv("INCLUDE");
bool hasSh = Environment::detectExecutable("sh.exe");
QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';'));
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index f9b3e85..78e1d87 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -120,6 +120,9 @@ QString Environment::detectQMakeSpec()
spec = "win32-icc";
break;
case CC_MINGW:
+ spec = "win32-g++-4.6";
+ break;
+ case CC_MINGW_44:
spec = "win32-g++";
break;
case CC_BORLAND:
@@ -173,6 +176,12 @@ Compiler Environment::detectCompiler()
if (executable.length() && Environment::detectExecutable(executable)) {
++installed;
detectedCompiler = compiler_info[i].compiler;
+ if (detectedCompiler == CC_MINGW) {
+ bool is64bit;
+ const int version = detectGPlusPlusVersion(executable, &is64bit);
+ if (version < 0x040600)
+ detectedCompiler = CC_MINGW_44;
+ }
break;
}
}
@@ -184,7 +193,7 @@ Compiler Environment::detectCompiler()
}
return detectedCompiler;
#endif
-};
+}
/*!
Returns true if the \a executable could be loaded, else false.
@@ -214,6 +223,81 @@ bool Environment::detectExecutable(const QString &executable)
}
/*!
+ Determine the g++ version.
+*/
+
+int Environment::detectGPlusPlusVersion(const QString &executable,
+ bool *is64bit)
+{
+ QRegExp regexp(QLatin1String("[gG]\\+\\+[\\.exEX]{0,4} ([^\\s]+) (\\d+)\\.(\\d+)\\.(\\d+)"));
+ QString stdOut = readProcessStandardOutput(executable + QLatin1String(" --version"));
+ if (regexp.indexIn(stdOut) != -1) {
+ const QString compiler = regexp.cap(1);
+ // Check for "tdm64-1"
+ *is64bit = compiler.contains(QLatin1String("64"));
+ const int major = regexp.cap(2).toInt();
+ const int minor = regexp.cap(3).toInt();
+ const int patch = regexp.cap(4).toInt();
+ return (major << 16) + (minor << 8) + patch;
+ }
+ *is64bit = false;
+ return 0;
+}
+
+/*!
+ Run a process and return its standard output.
+*/
+
+QString Environment::readProcessStandardOutput(const QString &commandLine)
+{
+ QString stdOut;
+ TCHAR tempFileName[MAX_PATH];
+ TCHAR tempPathBuffer[MAX_PATH];
+ if (!GetTempPath(MAX_PATH, tempPathBuffer)
+ || !GetTempFileName(tempPathBuffer, TEXT("qtconfigure"), 0, tempFileName))
+ return stdOut;
+
+ STARTUPINFO startInfo;
+ memset(&startInfo, 0, sizeof(startInfo));
+ startInfo.cb = sizeof(startInfo);
+ startInfo.dwFlags |= STARTF_USESTDHANDLES;
+
+ SECURITY_ATTRIBUTES securityAttributes;
+ securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
+ securityAttributes.bInheritHandle = TRUE;
+ securityAttributes.lpSecurityDescriptor = NULL;
+
+ startInfo.hStdOutput = CreateFile(tempFileName, GENERIC_WRITE, 0, &securityAttributes, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (startInfo.hStdOutput == INVALID_HANDLE_VALUE)
+ return stdOut;
+
+ PROCESS_INFORMATION procInfo;
+ memset(&procInfo, 0, sizeof(procInfo));
+
+ if (!CreateProcess(0, (wchar_t*)commandLine.utf16(),
+ 0, 0, TRUE,
+ 0,
+ 0, 0, &startInfo, &procInfo)) {
+ CloseHandle(startInfo.hStdOutput);
+ DeleteFile(tempFileName);
+ return stdOut;
+ }
+
+ WaitForSingleObject(procInfo.hProcess, INFINITE);
+ CloseHandle(procInfo.hThread);
+ CloseHandle(procInfo.hProcess);
+ CloseHandle(startInfo.hStdOutput);
+ QFile file(QString::fromWCharArray(tempFileName));
+
+ if (file.open(QIODevice::Text| QIODevice::ReadOnly)) {
+ stdOut = QString::fromLocal8Bit(file.readAll());
+ file.close();
+ }
+ DeleteFile(tempFileName);
+ return stdOut;
+}
+
+/*!
Creates a commandling from \a program and it \a arguments,
escaping characters that needs it.
*/
diff --git a/tools/configure/environment.h b/tools/configure/environment.h
index 9bbd096..81c232a 100644
--- a/tools/configure/environment.h
+++ b/tools/configure/environment.h
@@ -49,6 +49,7 @@ enum Compiler {
CC_UNKNOWN = 0,
CC_BORLAND = 0x01,
CC_MINGW = 0x02,
+ CC_MINGW_44 = 0x21,
CC_INTEL = 0x03,
CC_NET2003 = 0x71,
CC_NET2005 = 0x80,
@@ -63,6 +64,8 @@ public:
static Compiler detectCompiler();
static QString detectQMakeSpec();
static bool detectExecutable(const QString &executable);
+ static int detectGPlusPlusVersion(const QString &executable, bool *is64bit);
+ static QString readProcessStandardOutput(const QString &commandLine);
static int execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv);
static bool cpdir(const QString &srcDir,