From 7c0aa83527e0b0179f9e3f73a3e63df1fdc5a6e6 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Wed, 26 Jun 2019 16:04:12 +0200 Subject: [PATCH] package/qt5/qt5base: build with correct optimization Qt5 has predefined optimization flags depending if you're building for size, for debug etc. These flags are defined in mkspecs/common/gcc-base.conf: QMAKE_CFLAGS_OPTIMIZE = -O2 QMAKE_CFLAGS_OPTIMIZE_FULL = -O3 QMAKE_CFLAGS_OPTIMIZE_DEBUG = -Og QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os Then, in common/features/default_post.prf, they add those flags to QMAKE_CFLAGS_RELEASE/QMAKE_CXXFLAGS_RELEASE depending on various build options (optimize_size, optimize_full, optimize_debug): 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 QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE_FULL QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE_FULL } } Since this default_post.prf is included *after* our qmake.conf file, these flags override our optimizations flags, which is not good. However, our qmake.conf file is included *after* gcc-base.conf, so we can simply reset those variables to have the empty value, and our optimization flags will be used. Signed-off-by: Giulio Benetti [Thomas: completely change the approach, by simply resetting the QMAKE_CFLAGS_OPTIMIZE_* variables in qmake.conf] Signed-off-by: Thomas Petazzoni --- package/qt5/qt5base/qmake.conf.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/qt5/qt5base/qmake.conf.in b/package/qt5/qt5base/qmake.conf.in index 26bee2cb39..2eb564e172 100644 --- a/package/qt5/qt5base/qmake.conf.in +++ b/package/qt5/qt5base/qmake.conf.in @@ -15,6 +15,10 @@ QMAKE_CXX = $${CROSS_COMPILE}g++ # modifications to gcc-base.conf QMAKE_CFLAGS += $${BR_COMPILER_CFLAGS} QMAKE_CXXFLAGS += $${BR_COMPILER_CXXFLAGS} +QMAKE_CFLAGS_OPTIMIZE = +QMAKE_CFLAGS_OPTIMIZE_DEBUG = +QMAKE_CFLAGS_OPTIMIZE_FULL = +QMAKE_CFLAGS_OPTIMIZE_SIZE = CONFIG += nostrip QMAKE_LIBS += -lrt -lpthread -ldl -- 2.30.2