Skip to contentSkip to conversation

package/qt5/qt5base: drop wrong optimization flag

PATCH New Giulio Benetti 3 participants 6 messages Jun 26, 2019 – Aug 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/qt5/qt5base: drop wrong optimization flag

In qmake.conf.in has been left 'QMAKE_CXXFLAGS_RELEASE += -O3' but this leads to not use Buildroot CXXFLAGS when building in release mode(without debugging symbols). So let's remove it to let Qt5 to follow Buildroot optimization flags like other packages do.

---
 package/qt5/qt5base/qmake.conf.in | 1 -
 1 file changed, 1 deletion(-)
package/qt5/qt5base/qmake.conf.in +0 -1
index f14527aa7f..26bee2cb39 100644
@@ -15,7 +15,6 @@ QMAKE_CXX               = $${CROSS_COMPILE}g++
 # modifications to gcc-base.conf
 QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
 QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
-QMAKE_CXXFLAGS_RELEASE += -O3
 CONFIG                 += nostrip
 
 QMAKE_LIBS             += -lrt -lpthread -ldl
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 package/qt5/qt5base: build with correct optimization

Qt5 has predefined optimization flags depending if you're building for size, for debug etc. But this is a problem because those flags override Buildroot's TARGET_CFLAGS. In particular QMAKE_CFLAGS_OPTIMIZE_FULL is set to -O3 by default and when a qt5 module .pro file contains 'CONFIG += optimize_full', qmake appends QMAKE_CFLAGS_OPTIMIZE_FULL to CFLAGS. So the only consistent way that avoid patching qt5 to set optimization according to Buildroot is to set QMAKE_CFLAGS_OPTIMIZE_FULL = $(TARGET_OPTIMIZATION) by passing a new qt variable BR_OPTIMIZATION when calling qt5 ./configure.

---
 package/qt5/qt5base/qmake.conf.in | 1 +
 package/qt5/qt5base/qt5base.mk    | 1 +
 2 files changed, 2 insertions(+)
package/qt5/qt5base/qmake.conf.in +1 -0
index 26bee2cb39..4de880d2a2 100644
@@ -15,6 +15,7 @@ QMAKE_CXX               = $${CROSS_COMPILE}g++
 # modifications to gcc-base.conf
 QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
 QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+QMAKE_CFLAGS_OPTIMIZE_FULL  = $${BR_OPTIMIZATION}
 CONFIG                 += nostrip
 
 QMAKE_LIBS             += -lrt -lpthread -ldl
package/qt5/qt5base/qt5base.mk +1 -0
index e4aa76908a..69e90a37b3 100644
@@ -361,6 +361,7 @@ define QT5BASE_CONFIGURE_CMDS
 		-device-option CROSS_COMPILE="$(TARGET_CROSS)" \
 		-device-option BR_COMPILER_CFLAGS="$(QT5BASE_CFLAGS)" \
 		-device-option BR_COMPILER_CXXFLAGS="$(QT5BASE_CXXFLAGS)" \
+		-device-option BR_OPTIMIZATION="$(TARGET_OPTIMIZATION)" \
 		$(QT5BASE_CONFIGURE_OPTS) \
 	)
 endef
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 package/qt5/qt5base: build with correct optimization

Hello,

Quoted 17 lines · On Wed, 26 Jun 2019 16:04:12 +0200 Giulio Benetti…
package/qt5/qt5base/qmake.conf.in +1 -0
index 26bee2cb39..4de880d2a2 100644
@@ -15,6 +15,7 @@ QMAKE_CXX               = $${CROSS_COMPILE}g++
 # modifications to gcc-base.conf
 QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
 QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+QMAKE_CFLAGS_OPTIMIZE_FULL  = $${BR_OPTIMIZATION}
 CONFIG                 += nostrip
 
 QMAKE_LIBS             += -lrt -lpthread -ldl
package/qt5/qt5base/qt5base.mk +0 -0
index e4aa76908a..69e90a37b3 100644

package/qt5/qt5base/qt5base.mk define QT5BASE_CONFIGURE_CMDS · line 364

Quoted 4 lines
package/qt5/qt5base/qt5base.mk +1 -0
@@ -361,6 +361,7 @@ define QT5BASE_CONFIGURE_CMDS
 		-device-option CROSS_COMPILE="$(TARGET_CROSS)" \
 		-device-option BR_COMPILER_CFLAGS="$(QT5BASE_CFLAGS)" \
 		-device-option BR_COMPILER_CXXFLAGS="$(QT5BASE_CXXFLAGS)" \
+		-device-option BR_OPTIMIZATION="$(TARGET_OPTIMIZATION)" \

TARGET_OPTIMIZATION is already inside TARGET_CFLAGS, so it doesn't make a lot of sense to pass them again. Basically, it's just easier to set QMAKE_CFLAGS_OPTIMIZE, QMAKE_CFLAGS_OPTIMIZE_FULL, QMAKE_CFLAGS_OPTIMIZE_SIZE, QMAKE_CFLAGS_OPTIMIZE_DEBUG to the empty value. See the final commit at:

https://git.buildroot.org/buildroot/commit/?id=7c0aa83527e0b0179f9e3f73a3e63df1fdc5a6e6

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 2/2 package/qt5/qt5base: build with correct optimization

Hello Thomas,

Il 03/08/2019 12:21, Thomas Petazzoni ha scritto:

Quoted 33 lines

Hello,

Quoted 17 lines · On Wed, 26 Jun 2019 16:04:12 +0200 Giulio Benetti…
package/qt5/qt5base/qmake.conf.in +1 -0
index 26bee2cb39..4de880d2a2 100644
@@ -15,6 +15,7 @@ QMAKE_CXX               = $${CROSS_COMPILE}g++
  # modifications to gcc-base.conf
  QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
  QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+QMAKE_CFLAGS_OPTIMIZE_FULL  = $${BR_OPTIMIZATION}
  CONFIG                 += nostrip
 
  QMAKE_LIBS             += -lrt -lpthread -ldl
package/qt5/qt5base/qt5base.mk +0 -0
index e4aa76908a..69e90a37b3 100644

package/qt5/qt5base/qt5base.mk define QT5BASE_CONFIGURE_CMDS · line 364

Quoted 4 lines
package/qt5/qt5base/qt5base.mk +1 -0
@@ -361,6 +361,7 @@ define QT5BASE_CONFIGURE_CMDS
  		-device-option CROSS_COMPILE="$(TARGET_CROSS)" \
  		-device-option BR_COMPILER_CFLAGS="$(QT5BASE_CFLAGS)" \
  		-device-option BR_COMPILER_CXXFLAGS="$(QT5BASE_CXXFLAGS)" \
+		-device-option BR_OPTIMIZATION="$(TARGET_OPTIMIZATION)" \

TARGET_OPTIMIZATION is already inside TARGET_CFLAGS, so it doesn't make a lot of sense to pass them again. Basically, it's just easier to set QMAKE_CFLAGS_OPTIMIZE, QMAKE_CFLAGS_OPTIMIZE_FULL, QMAKE_CFLAGS_OPTIMIZE_SIZE, QMAKE_CFLAGS_OPTIMIZE_DEBUG to the empty value. See the final commit at:

Quoted 1 line
   https://git.buildroot.org/buildroot/commit/?id=7c0aa83527e0b0179f9e3f73a3e63df1fdc5a6e6

Good idea to override them in qmake.conf.in, I didn't think about it.

Thank you

Signature · 10 lines
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale ? 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642
#4 lore raw

PATCH 1/2 package/qt5/qt5base: drop wrong optimization flag

In reply to Giulio Benetti
Quoted 9 lines · On Wed, 26 Jun 2019 16:04:11 +0200 Giulio Benetti…

In qmake.conf.in has been left 'QMAKE_CXXFLAGS_RELEASE += -O3' but this leads to not use Buildroot CXXFLAGS when building in release mode(without debugging symbols). So let's remove it to let Qt5 to follow Buildroot optimization flags like other packages do.

---
 package/qt5/qt5base/qmake.conf.in | 1 -
 1 file changed, 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 1/2 package/qt5/qt5base: drop wrong optimization flag

In reply to Giulio Benetti
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Giulio" == Giulio Benetti <[email protected]> writes:

In qmake.conf.in has been left 'QMAKE_CXXFLAGS_RELEASE += -O3' but this leads to not use Buildroot CXXFLAGS when building in release mode(without debugging symbols). So let's remove it to let Qt5 to follow Buildroot optimization flags like other packages do.

Committed to 2019.02.x and 2019.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard