summaryrefslogtreecommitdiffstats
path: root/tools/configure
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@rim.com>2012-09-20 12:11:25 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-14 08:56:08 (GMT)
commite25f67d3e6ba6aa24a355010e0dc3baadbbacb8b (patch)
tree230af0f7d8e04348a97ce274615a45e5b3ff2d41 /tools/configure
parent3fbc68b372741d04f477915bb09efbd2a277a570 (diff)
downloadQt-e25f67d3e6ba6aa24a355010e0dc3baadbbacb8b.zip
Qt-e25f67d3e6ba6aa24a355010e0dc3baadbbacb8b.tar.gz
Qt-e25f67d3e6ba6aa24a355010e0dc3baadbbacb8b.tar.bz2
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. Original-patch-by: Greg Bentz (cherry picked from commit 80f6d7862c0e2e41768620d5bd81b0e1d5e3f61f) Change-Id: I5867fc03dde1ef6e2fbf3747bdb9aaf15518eb6a Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tools/configure')
-rw-r--r--tools/configure/configureapp.cpp36
-rw-r--r--tools/configure/configureapp.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index be28762..21131b6 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1724,6 +1724,7 @@ void Configure::applySpecSpecifics()
dictionary[ "FONT_CONFIG" ] = "yes";
dictionary[ "FONT_CONFIG" ] = "yes";
dictionary[ "FREETYPE" ] = "system";
+ dictionary[ "STACK_PROTECTOR_STRONG" ] = "auto";
}
}
@@ -2401,6 +2402,11 @@ bool Configure::checkAvailability(const QString &part)
}
} else if (part == "DIRECTWRITE") {
available = findFile("dwrite.h") && findFile("d2d1.h") && findFile("dwrite.lib");
+ } else if (part == "STACK_PROTECTOR_STRONG") {
+ QStringList compilerAndArgs;
+ compilerAndArgs += "qcc";
+ compilerAndArgs += "-fstack-protector-strong";
+ available = dictionary[ "XQMAKESPEC" ].contains("blackberry") && compilerSupportsFlag(compilerAndArgs);
}
return available;
@@ -2504,6 +2510,10 @@ void Configure::autoDetection()
if (dictionary["INCREDIBUILD_XGE"] == "auto")
dictionary["INCREDIBUILD_XGE"] = checkAvailability("INCREDIBUILD_XGE") ? "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")
@@ -2979,6 +2989,9 @@ void Configure::generateOutputVars()
// We currently have no switch for QtSvg, so add it unconditionally.
qtConfig += "svg";
+ if (dictionary["STACK_PROTECTOR_STRONG"] == "yes")
+ qtConfig += "stack-protector-strong";
+
// We currently have no switch for QtConcurrent, so add it unconditionally.
qtConfig += "concurrent";
@@ -4426,6 +4439,29 @@ void Configure::saveCmdLine()
}
#endif // !EVAL
+bool Configure::compilerSupportsFlag(const QStringList &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
+ QStringList command = compilerAndArgs;
+ command += "-o";
+ command += "conftest-out.o";
+ command += "conftest.cpp";
+ int code = Environment::execute(command, QStringList(), QStringList());
+ file.remove();
+ QFile::remove("conftest-out.o");
+ return code == 0;
+}
+
bool Configure::isDone()
{
return !dictionary["DONE"].isEmpty();
diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h
index ee34b0d..d3f4ca1 100644
--- a/tools/configure/configureapp.h
+++ b/tools/configure/configureapp.h
@@ -161,6 +161,8 @@ private:
void saveCmdLine();
#endif
+ bool compilerSupportsFlag(const QStringList &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 = '.');
void desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar = '.');