summaryrefslogtreecommitdiffstats
path: root/tools/configure
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@rim.com>2012-09-20 14:11:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-01 10:22:06 +0200
commit80f6d7862c0e2e41768620d5bd81b0e1d5e3f61f (patch)
tree9e06efdf82597af4ed89ce5200aca898a137fba9 /tools/configure
parentc6271071b4d0686fef8fe3df215ce84be0305a8b (diff)
Blackberry mkspecs: Refine compiler options
stack-protector-strong gives performance benefits over stack-protector-all and is still checking more than -stack-protector, so seems to be a good middle way and we want to use it when it is there. The -shared option for the compiler (not the linker) prevents a RIM internal version of qcc from forcing -fPIE, and should not harm in general when set. In addition, add a method "compilerSupportsFlag" for Windows as is present in the Unix configure script. Change-Id: Iba300e9cb82f34043e7b36f8e45287a1aed2a1a5 Original-patch-by: Greg Bentz Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tools/configure')
-rw-r--r--tools/configure/configureapp.cpp32
-rw-r--r--tools/configure/configureapp.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 4fce6f21d7..d1244f0f59 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1504,6 +1504,8 @@ void Configure::applySpecSpecifics()
dictionary[ "QT_ICONV" ] = "no";
dictionary["DECORATIONS"] = "default windows styled";
+ } else if ((platform() == QNX) || (platform() == BLACKBERRY)) {
+ dictionary["STACK_PROTECTOR_STRONG"] = "auto";
}
}
@@ -2041,6 +2043,8 @@ bool Configure::checkAvailability(const QString &part)
available = tryCompileProject("unix/iconv") || tryCompileProject("unix/gnu-libiconv");
} else if (part == "CUPS") {
available = (platform() != WINDOWS) && (platform() != WINDOWS_CE) && tryCompileProject("unix/cups");
+ } else if (part == "STACK_PROTECTOR_STRONG") {
+ available = (platform() == QNX || platform() == BLACKBERRY) && compilerSupportsFlag("qcc -fstack-protector-strong");
}
return available;
@@ -2153,6 +2157,10 @@ void Configure::autoDetection()
if (dictionary["QT_CUPS"] == "auto")
dictionary["QT_CUPS"] = checkAvailability("CUPS") ? "yes" : "no";
+ // Detection of -fstack-protector-strong support
+ if (dictionary["STACK_PROTECTOR_STRONG"] == "auto")
+ dictionary["STACK_PROTECTOR_STRONG"] = checkAvailability("STACK_PROTECTOR_STRONG") ? "yes" : "no";
+
// Mark all unknown "auto" to the default value..
for (QMap<QString,QString>::iterator i = dictionary.begin(); i != dictionary.end(); ++i) {
if (i.value() == "auto")
@@ -2511,6 +2519,9 @@ void Configure::generateOutputVars()
if (dictionary["QT_GLIB"] == "yes")
qtConfig += "glib";
+ if (dictionary["STACK_PROTECTOR_STRONG"] == "yes")
+ qtConfig += "stack-protector-strong";
+
// We currently have no switch for QtConcurrent, so add it unconditionally.
qtConfig += "concurrent";
@@ -2872,6 +2883,27 @@ bool Configure::tryCompileProject(const QString &projectPath, const QString &ext
return code == 0;
}
+bool Configure::compilerSupportsFlag(const QString &compilerAndArgs)
+{
+ QFile file("conftest.cpp");
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ cout << "could not open temp file for writing" << endl;
+ return false;
+ }
+ if (!file.write("int main() { return 0; }\r\n")) {
+ cout << "could not write to temp file" << endl;
+ return false;
+ }
+ file.close();
+ // compilerAndArgs contains compiler because there is no way to query it
+ QString command = compilerAndArgs + " -o conftest-out.o conftest.cpp";
+ int code = 0;
+ QString output = Environment::execute(command, &code);
+ file.remove();
+ QFile::remove("conftest-out.o");
+ return code == 0;
+}
+
void Configure::generateQConfigPri()
{
// Generate qconfig.pri
diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h
index 3261f4f80d..8cae9da4f8 100644
--- a/tools/configure/configureapp.h
+++ b/tools/configure/configureapp.h
@@ -175,6 +175,7 @@ private:
#endif
bool tryCompileProject(const QString &projectPath, const QString &extraOptions = QString());
+ bool compilerSupportsFlag(const QString &compilerAndArgs);
void desc(const char *description, int startingAt = 0, int wrapIndent = 0);
void desc(const char *option, const char *description, bool skipIndent = false, char fillChar = '.');