From d03ba0e895a3719ce527f3d7ee9262fb26065332 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Nov 2016 15:01:59 +0100 Subject: 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 --- config_help.txt | 2 ++ configure.json | 16 ++++++++++++++++ mkspecs/common/gcc-base.conf | 1 + mkspecs/features/default_post.prf | 5 +++++ src/gui/text/qfontengine.cpp | 2 +- .../deviceintegration/eglfs_x11/qeglfsx11integration.cpp | 2 +- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config_help.txt b/config_help.txt index ab86873310..e5553025c5 100644 --- a/config_help.txt +++ b/config_help.txt @@ -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] diff --git a/configure.json b/configure.json index 4030d359ae..c293fbb676 100644 --- a/configure.json +++ b/configure.json @@ -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", diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 6bb1e3fbe0..0ee8769bf2 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -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 diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 7f5ab3a10c..e19e9c9760 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -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 diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 8d8ca1ba2c..596c79fd05 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -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; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 0a547b832f..64d0d9b515 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -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) { -- cgit v1.2.3