diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-04-07 15:49:10 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-04-29 08:02:19 +0000 |
commit | dd03817ab6626c6c85bf7bf65532f33824e46bf8 (patch) | |
tree | 6658ae2cc17281d038267f0f86512165c6aec662 | |
parent | 425986acf32a60288a8a2ed9b3b2b180f60b5514 (diff) | |
download | qtbase-dd03817ab6626c6c85bf7bf65532f33824e46bf8.tar.gz |
Add configure flag to optimize Qt for size
Adds default off configure flag to use compiler optimizations
for size instead of the default speed/size trade-off.
Change-Id: I36702064ef2cc743d2d03a386adf5cefd5371b6e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
-rw-r--r-- | config_help.txt | 1 | ||||
-rw-r--r-- | configure.json | 12 | ||||
-rw-r--r-- | mkspecs/common/gcc-base.conf | 1 | ||||
-rw-r--r-- | mkspecs/common/msvc-desktop.conf | 7 | ||||
-rw-r--r-- | mkspecs/features/default_post.prf | 9 | ||||
-rw-r--r-- | mkspecs/linux-icc/qmake.conf | 5 | ||||
-rw-r--r-- | mkspecs/macx-icc/qmake.conf | 5 |
7 files changed, 35 insertions, 5 deletions
diff --git a/config_help.txt b/config_help.txt index 317ba61031..2cf8c8d885 100644 --- a/config_help.txt +++ b/config_help.txt @@ -83,6 +83,7 @@ Build options: debugging turned on [yes] (Apple and Windows only) -optimize-debug ...... Enable debug-friendly optimizations in debug builds [auto] (Not supported with MSVC) + -optimize-size ....... Optimize release builds for size instead of speed [no] -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 06c62f5aea..49586ed6b8 100644 --- a/configure.json +++ b/configure.json @@ -93,6 +93,7 @@ "nomake": { "type": "addString", "values": [ "examples", "tests", "tools" ] }, "opensource": { "type": "void", "name": "commercial", "value": "no" }, "optimize-debug": { "type": "boolean", "name": "optimize_debug" }, + "optimize-size": { "type": "boolean", "name": "optimize_size" }, "optimized-qmake": { "type": "boolean", "name": "release_tools" }, "optimized-tools": { "type": "boolean", "name": "release_tools" }, "pch": { "type": "boolean", "name": "precompile_header" }, @@ -485,6 +486,12 @@ "condition": "!config.msvc && (features.debug || features.debug_and_release) && tests.optimize_debug", "output": [ "privateConfig" ] }, + "optimize_size": { + "label": "Optimize release build for size", + "autoDetect": false, + "condition": "!features.debug || features.debug_and_release", + "output": [ "privateConfig" ] + }, "architecture": { "label": "Architecture", "output": [ "architecture" ] @@ -1090,6 +1097,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "args": "optimize_debug", "condition": "!config.msvc && (features.debug || features.debug_and_release)" }, + { + "type": "feature", + "args": "optimize_size", + "condition": "!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 9ddebae506..e7e6ee1815 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -34,6 +34,7 @@ QMAKE_CFLAGS_OPTIMIZE = -O2 QMAKE_CFLAGS_OPTIMIZE_FULL = -O3 QMAKE_CFLAGS_OPTIMIZE_DEBUG = -Og +QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os QMAKE_CFLAGS += -pipe QMAKE_CFLAGS_DEPS += -M diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf index 02b8441547..d0d8869036 100644 --- a/mkspecs/common/msvc-desktop.conf +++ b/mkspecs/common/msvc-desktop.conf @@ -19,6 +19,9 @@ contains(QMAKE_TARGET.arch, x86_64) { QMAKE_COMPILER_DEFINES += _WIN64 } +QMAKE_CFLAGS_OPTIMIZE = -O2 +QMAKE_CFLAGS_OPTIMIZE_SIZE = -O1 + QMAKE_CC = cl QMAKE_LEX = flex QMAKE_LEXFLAGS = @@ -27,8 +30,8 @@ QMAKE_YACCFLAGS = -d QMAKE_CFLAGS = -nologo -Zc:wchar_t QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi +QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MD +QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -MD -Zi QMAKE_CFLAGS_DEBUG = -Zi -MDd QMAKE_CFLAGS_YACC = QMAKE_CFLAGS_LTCG = -GL diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 6d6707d6bb..d6caf870f7 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -38,7 +38,14 @@ force_debug_info { QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO } -optimize_full { +optimize_size { + !isEmpty(QMAKE_CFLAGS_OPTIMIZE):!isEmpty(QMAKE_CFLAGS_OPTIMIZE_SIZE) { + QMAKE_CFLAGS_RELEASE -= $$QMAKE_CFLAGS_OPTIMIZE + QMAKE_CXXFLAGS_RELEASE -= $$QMAKE_CFLAGS_OPTIMIZE + QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE_SIZE + QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE_SIZE + } +} else: optimize_full { !isEmpty(QMAKE_CFLAGS_OPTIMIZE):!isEmpty(QMAKE_CFLAGS_OPTIMIZE_FULL) { QMAKE_CFLAGS_RELEASE -= $$QMAKE_CFLAGS_OPTIMIZE QMAKE_CXXFLAGS_RELEASE -= $$QMAKE_CFLAGS_OPTIMIZE diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index 582420ffee..4fc2251665 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -6,6 +6,9 @@ MAKEFILE_GENERATOR = UNIX QMAKE_COMPILER = gcc intel_icc # icc pretends to be gcc +QMAKE_CFLAGS_OPTIMIZE = -O2 +QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os + QMAKE_CC = icc QMAKE_LEX = flex QMAKE_LEXFLAGS = @@ -16,7 +19,7 @@ QMAKE_CFLAGS_APP = -fPIC QMAKE_CFLAGS_DEPS = -M QMAKE_CFLAGS_WARN_ON = -w1 -Wall -Wcheck -wd1572,873,2259,2261,3373 QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 +QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE QMAKE_CFLAGS_DEBUG = -O0 -g QMAKE_CFLAGS_SHLIB = -fPIC QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf index 7e10d1f413..e999aa36a4 100644 --- a/mkspecs/macx-icc/qmake.conf +++ b/mkspecs/macx-icc/qmake.conf @@ -11,12 +11,15 @@ QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__ QMAKE_COMPILER = gcc clang intel_icc # icc pretends to be gcc and clang +QMAKE_CFLAGS_OPTIMIZE = -O2 +QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os + QMAKE_CC = icc QMAKE_CFLAGS = QMAKE_CFLAGS_DEPS = -M QMAKE_CFLAGS_WARN_ON = -w1 -Wcheck -wd654,1572,411,873,1125,2259,2261,3280,3373 QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 +QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE QMAKE_CFLAGS_DEBUG = -g -O0 QMAKE_CFLAGS_SHLIB = -fPIC QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB |