Optimize debug builds when -Og is available

Enables optimizing with -Og if GCC has the option available, this
should produce faster debug binaries without compromising debugability.

Is a privateConfig to limit it to the default Qt build.

Includes two fixes for false positives of maybe_uninitialized triggered
by -Og on gcc 4.9.

Change-Id: I466d7a4070295714189024369312e6cbd36cfacf
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2016-11-17 15:01:59 +01:00
parent aab8e304ea
commit d03ba0e895
6 changed files with 26 additions and 2 deletions

View File

@ -72,6 +72,8 @@ Build options:
-debug ............... Build Qt with debugging turned on [no]
-debug-and-release ... Build two versions of Qt, with and without
debugging turned on [yes] (Apple and Windows only)
-optimize-debug ...... Enable debug-friendly optimizations in debug builds
[auto] (Not supported with MSVC)
-optimized-tools ..... Build optimized host tools even in debug build [no]
-force-debug-info .... Create symbol files for release builds [no]
-separate-debug-info . Split off debug information to separate files [no]

View File

@ -93,6 +93,7 @@
"mp": { "type": "boolean", "name": "msvc_mp" },
"nomake": { "type": "addString", "values": [ "examples", "tests", "tools" ] },
"opensource": { "type": "void", "name": "commercial", "value": "no" },
"optimize-debug": { "type": "boolean", "name": "optimize_debug" },
"optimized-qmake": { "type": "boolean", "name": "release_tools" },
"optimized-tools": { "type": "boolean", "name": "release_tools" },
"pch": { "type": "boolean", "name": "precompile_header" },
@ -263,6 +264,11 @@
"type": "compilerSupportsFlag",
"flag": "-fuse-ld=gold"
},
"optimize_debug": {
"label": "-Og support",
"type": "compilerSupportsFlag",
"flag": "-Og"
},
"enable_new_dtags": {
"label": "new dtags support",
"type": "linkerSupportsFlag",
@ -479,6 +485,11 @@
"condition": "!config.msvc && !config.integrity && tests.use_gold_linker",
"output": [ "privateConfig", "useGoldLinker" ]
},
"optimize_debug": {
"label": "Optimize debug build",
"condition": "!config.msvc && (features.debug || features.debug_and_release) && tests.optimize_debug",
"output": [ "privateConfig" ]
},
"architecture": {
"label": "Architecture",
"output": [ "architecture" ]
@ -1078,6 +1089,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
"message": "Mode",
"type": "buildMode"
},
{
"type": "feature",
"args": "optimize_debug",
"condition": "!config.msvc && (features.debug || features.debug_and_release)"
},
"shared",
{
"message": "Using C++ standard",

View File

@ -33,6 +33,7 @@
QMAKE_CFLAGS_OPTIMIZE = -O2
QMAKE_CFLAGS_OPTIMIZE_FULL = -O3
QMAKE_CFLAGS_OPTIMIZE_DEBUG = -Og
QMAKE_CFLAGS += -pipe
QMAKE_CFLAGS_DEPS += -M

View File

@ -47,6 +47,11 @@ optimize_full {
}
}
optimize_debug {
QMAKE_CFLAGS_DEBUG += $$QMAKE_CFLAGS_OPTIMIZE_DEBUG
QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_OPTIMIZE_DEBUG
}
debug {
QMAKE_CFLAGS += $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_DEBUG

View File

@ -1273,7 +1273,7 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId))
return 0;
quint16 platformSpecificId;
quint16 platformSpecificId = 0;
if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId))
return 0;

View File

@ -114,7 +114,7 @@ void EventReader::run()
{
Qt::MouseButtons buttons;
xcb_generic_event_t *event;
xcb_generic_event_t *event = nullptr;
while (running.load() && (event = xcb_wait_for_event(m_integration->connection()))) {
uint response_type = event->response_type & ~0x80;
switch (response_type) {