Skip to contentSkip to conversation

remove optimize by default while using qmake

PATCH In review Mehmet Sami Tok 2 participants 5 messages Jan 7, 2020 – Aug 6, 2021

lore
Share & tools
lore
#0 lore raw

cover remove optimize by default while using qmake

When building qt projects with debug configuration on a host computer, applications build with optimization even if not configured to.

Optimization flags in TARGET_CFLAGS are passed as default build arguments of qt build commands. If they are not overriden or removed manually from build arguments, any project build with optimization level of root file system by default.

So I filtered optimization flags which are passed to "config.opt" first, then made into "mkspecs/qdevice.pri".

Mehmet Sami Tok (1):
package/qt5: remove optimize by default on debug builds made with
qmake

 package/qt5/qt5base/qt5base.mk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 package/qt5: remove optimize by default on debug builds made with qmake

---
 package/qt5/qt5base/qt5base.mk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/qt5/qt5base/qt5base.mk +6 -2
index 774c771bc9..3415172fcb 100644
@@ -34,8 +34,12 @@ ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y)
 QT5BASE_CONFIGURE_OPTS += -no-optimize-debug
 endif
 
-QT5BASE_CFLAGS = $(TARGET_CFLAGS)
-QT5BASE_CXXFLAGS = $(TARGET_CXXFLAGS)
+# Passing optimization flags directly to CFLAGS or CXXFLAGS makes qmake
+# builds optimized by default. Decision of optimization while developing
+# with qmake should be leaved to configuration of the project.
+FILTERED_ITEMS = -O%
+QT5BASE_CFLAGS = $(filter-out $(FILTERED_ITEMS),$(TARGET_CFLAGS))
+QT5BASE_CXXFLAGS = $(filter-out $(FILTERED_ITEMS),$(TARGET_CXXFLAGS))
 
 ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_90620),y)
 QT5BASE_CFLAGS += -O0
Signature · 1 line
2.17.1
#2 lore raw

Re: [Buildroot] [PATCH 1/1] package/qt5: remove optimize by default on debug builds made with qmake

Hello Mehmet,

Quoted 6 lines · On Tue, 7 Jan 2020 15:32:09 +0300 Mehmet Sami Tok <[email protected]>…
package/qt5/qt5base/qt5base.mk +0 -0
index 774c771bc9..3415172fcb 100644
@@ -34,8 +34,12 @@ ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y)
 QT5BASE_CONFIGURE_OPTS += -no-optimize-debug

package/qt5/qt5base/qt5base.mk ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y) · line 42

Quoted 10 lines
package/qt5/qt5base/qt5base.mk +6 -2
 endif
 
-QT5BASE_CFLAGS = $(TARGET_CFLAGS)
-QT5BASE_CXXFLAGS = $(TARGET_CXXFLAGS)
+# Passing optimization flags directly to CFLAGS or CXXFLAGS makes qmake
+# builds optimized by default. Decision of optimization while developing
+# with qmake should be leaved to configuration of the project.
+FILTERED_ITEMS = -O%
+QT5BASE_CFLAGS = $(filter-out $(FILTERED_ITEMS),$(TARGET_CFLAGS))
+QT5BASE_CXXFLAGS = $(filter-out $(FILTERED_ITEMS),$(TARGET_CXXFLAGS))

Thanks for your patch, and sorry for the long delay in providing feedback to you and your patch. However, what the code currently does it what we want: we want the optimization level defined at the Buildroot configuration level to apply to all packages. We certainly do not want individual packages to pick and chose their own optimization level. So basically, your proposal unfortunately goes against the very principle of Buildroot. For this reason, I'm afraid we have to reject your patch.

Best regards,

Thomas Petazzoni

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 1/1] package/qt5: remove optimize by default on debug builds made with qmake

Hi Thomas,
Thanks for the response. This is an old patch and I don't know if the problem is still there. But the main point of this patch was not changing flags of Qt package build.
When you want to use gcc toolchain and qmake generated by buildroot, It was affecting your application builds. These flags directly passed to qt toolchain and even if you want to build a debug build of any application, it is built with -o2. So the problem is not occuring when root file system is created, it appears when you want to build something else with toolchain generated by buildroot.

Best Regards,
Mehmet Sami Tok

Thomas Petazzoni <[email protected]>, 5 Ağu 2021 Per, 23:03 tarihinde şunu yazdı:

Quoted 40 lines

Hello Mehmet,

package/qt5/qt5base/

Quoted 1 line · On Tue, 7 Jan 2020 15:32:09 +0300 Mehmet Sami Tok <[email protected]>…
package/qt5/qt5base/ renamed from package/qt5/qt5base/qt5base.mk +0 -0

qt5base.mk

Quoted 5 lines

index 774c771bc9..3415172fcb 100644

package/qt5/qt5base/qt5base.mk +0 -0
@@ -34,8 +34,12 @@ ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y)
 QT5BASE_CONFIGURE_OPTS += -no-optimize-debug

package/qt5/qt5base/qt5base.mk ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y) · line 42

Quoted 10 lines
package/qt5/qt5base/qt5base.mk +6 -2
 endif
 
-QT5BASE_CFLAGS = $(TARGET_CFLAGS)
-QT5BASE_CXXFLAGS = $(TARGET_CXXFLAGS)
+# Passing optimization flags directly to CFLAGS or CXXFLAGS makes qmake
+# builds optimized by default. Decision of optimization while developing
+# with qmake should be leaved to configuration of the project.
+FILTERED_ITEMS = -O%
+QT5BASE_CFLAGS = $(filter-out $(FILTERED_ITEMS),$(TARGET_CFLAGS))
+QT5BASE_CXXFLAGS = $(filter-out $(FILTERED_ITEMS),$(TARGET_CXXFLAGS))

Thanks for your patch, and sorry for the long delay in providing feedback to you and your patch. However, what the code currently does it what we want: we want the optimization level defined at the Buildroot configuration level to apply to all packages. We certainly do not want individual packages to pick and chose their own optimization level. So basically, your proposal unfortunately goes against the very principle of Buildroot. For this reason, I'm afraid we have to reject your patch.

Best regards,

Thomas Petazzoni
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Signature · 3 lines
Best Regards,
İyi Günler Dilerim,
Mehmet Sami Tok

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

Re: [Buildroot] [PATCH 1/1] package/qt5: remove optimize by default on debug builds made with qmake

Hello Mehmet,

Quoted 9 lines · On Fri, 6 Aug 2021 14:39:07 +0300 Mehmet Sami Tok <[email protected]>…

Thanks for the response. This is an old patch and I don't know if the problem is still there. But the main point of this patch was not changing flags of Qt package build.
When you want to use gcc toolchain and qmake generated by buildroot, It was affecting your application builds. These flags directly passed to qt toolchain and even if you want to build a debug build of any application, it is built with -o2. So the problem is not occuring when root file system is created, it appears when you want to build something else with toolchain generated by buildroot.

I see. Indeed in this case we might consider that we should obey to the particular flags you specify rather than the ones from the Buildroot configuration.

However, unless I misread your patch, it removed optimization flags even for qmake packages built within Buildroot, which is not what we want.

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot