Skip to contentSkip to conversation

package/qt5base: fix building with correct optimization

PATCH Superseded Giulio Benetti 3 participants 5 messages Nov 25, 2019 – Mar 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package/qt5base: fix building 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 the same file, they use them to set
QMAKE_CFLAGS_RELEASE/QMAKE_CXXFLAGS_RELEASE:

QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE

At this point there is our chance to override QMAKE_CFLAGS_OPTIMIZE_* in qmake.conf, but it's too late, because QMAKE_CFLAGS_RELEASE is already set(i.e. -O2) so trying to add or remove QMAKE_CFLAGS_OPTIMIZE(that is reset now on) from QMAKE_CLAGS_RELEASE in common/features/default_post.prf won't work:

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
    }
}

So let's reset:
QMAKE_CFLAGS_RELEASE
QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG
in our qmake.conf.in since the only assignment done in mkspecs/common/gcc-base.conf only regards optimization.

This package is also affected by BR2_TOOLCHAIN_HAS_GCC_BUG_90620 and it's been worked around by appending -O0 to CFLAGS/CXXFLAGS. This bug prevented workaround to work overriding optimization flags, so solving this also solves workaround problem.

Fixes:
http://autobuild.buildroot.net/results/ada/adaa9b4bcc6f9d2b5e82c479859a07e8abf5cf13/
http://autobuild.buildroot.net/results/a83/a83bdd1f3bf309c07abebe871b017c331ed36e67/

---
V1->V2:
* rewritten entire commit log
V2->V3:
* rewritten entire commit log again trying to explain better

---
 package/qt5/qt5base/qmake.conf.in | 4 ++++
 1 file changed, 4 insertions(+)
package/qt5/qt5base/qmake.conf.in +4 -0
index 2eb564e172..ae25b2e20f 100644
@@ -19,6 +19,10 @@ QMAKE_CFLAGS_OPTIMIZE       =
 QMAKE_CFLAGS_OPTIMIZE_DEBUG =
 QMAKE_CFLAGS_OPTIMIZE_FULL  =
 QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
 CONFIG                 += nostrip
 
 QMAKE_LIBS             += -lrt -lpthread -ldl
Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 1/1 package/qt5base: fix building with correct optimization

+Fabrice.

Quoted 50 lines · Giulio Benetti

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 the same file, they use them to set
QMAKE_CFLAGS_RELEASE/QMAKE_CXXFLAGS_RELEASE:

QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE

At this point there is our chance to override QMAKE_CFLAGS_OPTIMIZE_* in qmake.conf, but it's too late, because QMAKE_CFLAGS_RELEASE is already set(i.e. -O2) so trying to add or remove QMAKE_CFLAGS_OPTIMIZE(that is reset now on) from QMAKE_CLAGS_RELEASE in common/features/default_post.prf won't work:

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
     }
}

So let's reset:
QMAKE_CFLAGS_RELEASE
QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG
in our qmake.conf.in since the only assignment done in mkspecs/common/gcc-base.conf only regards optimization.

This package is also affected by BR2_TOOLCHAIN_HAS_GCC_BUG_90620 and it's been worked around by appending -O0 to CFLAGS/CXXFLAGS. This bug prevented workaround to work overriding optimization flags, so solving this also solves workaround problem.

Quoted 5 lines

Fixes:
http://autobuild.buildroot.net/results/ada/adaa9b4bcc6f9d2b5e82c479859a07e8abf5cf13/
http://autobuild.buildroot.net/results/a83/a83bdd1f3bf309c07abebe871b017c331ed36e67/

According to: https://patchwork.ozlabs.org/patch/1215790/

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 25 lines

---
V1->V2:
* rewritten entire commit log
V2->V3:
* rewritten entire commit log again trying to explain better

---
  package/qt5/qt5base/qmake.conf.in | 4 ++++
  1 file changed, 4 insertions(+)
package/qt5/qt5base/qmake.conf.in +4 -0
index 2eb564e172..ae25b2e20f 100644
@@ -19,6 +19,10 @@ QMAKE_CFLAGS_OPTIMIZE       =
  QMAKE_CFLAGS_OPTIMIZE_DEBUG =
  QMAKE_CFLAGS_OPTIMIZE_FULL  =
  QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
  CONFIG                 += nostrip
 
  QMAKE_LIBS             += -lrt -lpthread -ldl
#2 lore raw

PATCH v3 1/1 package/qt5base: fix building with correct optimization

In reply to Giulio Benetti
Quoted 21 lines · Giulio Benetti

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 the same file, they use them to set
QMAKE_CFLAGS_RELEASE/QMAKE_CXXFLAGS_RELEASE:

QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE

At this point there is our chance to override QMAKE_CFLAGS_OPTIMIZE_* in qmake.conf, but it's too late, because QMAKE_CFLAGS_RELEASE is already set(i.e. -O2) so trying to add or remove QMAKE_CFLAGS_OPTIMIZE(that is reset now on) from QMAKE_CLAGS_RELEASE in common/features/default_post.prf won't work:

Quoted 15 lines
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
    }
}

This stuff is complicated...

Quoted 8 lines

So let's reset:
QMAKE_CFLAGS_RELEASE
QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG
in our qmake.conf.in since the only assignment done in mkspecs/common/gcc-base.conf only regards optimization.

But that's a really elegant solution!

package/qt5/qt5base/qmake.conf.in QMAKE_CFLAGS_OPTIMIZE =

Quoted 25 lines

This package is also affected by BR2_TOOLCHAIN_HAS_GCC_BUG_90620 and it's been worked around by appending -O0 to CFLAGS/CXXFLAGS. This bug prevented workaround to work overriding optimization flags, so solving this also solves workaround problem.

Fixes:
http://autobuild.buildroot.net/results/ada/adaa9b4bcc6f9d2b5e82c479859a07e8abf5cf13/
http://autobuild.buildroot.net/results/a83/a83bdd1f3bf309c07abebe871b017c331ed36e67/

---
V1->V2:
* rewritten entire commit log
V2->V3:
* rewritten entire commit log again trying to explain better

---
 package/qt5/qt5base/qmake.conf.in | 4 ++++
 1 file changed, 4 insertions(+)
package/qt5/qt5base/qmake.conf.in +0 -0
index 2eb564e172..ae25b2e20f 100644
@@ -19,6 +19,10 @@ QMAKE_CFLAGS_OPTIMIZE       =

I've added a comment above "Remove all optimisation flags, we really only want
our own."

Applied to master, thanks.

Regards,
Arnout

Quoted 11 lines
package/qt5/qt5base/qmake.conf.in +4 -0
 QMAKE_CFLAGS_OPTIMIZE_DEBUG =
 QMAKE_CFLAGS_OPTIMIZE_FULL  =
 QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
 CONFIG                 += nostrip
 
 QMAKE_LIBS             += -lrt -lpthread -ldl
#3 lore raw

PATCH v3 1/1 package/qt5base: fix building with correct optimization

Quoted 51 lines · Arnout Vandecappelle
Quoted 21 lines · Giulio Benetti

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 the same file, they use them to set
QMAKE_CFLAGS_RELEASE/QMAKE_CXXFLAGS_RELEASE:

QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE

At this point there is our chance to override QMAKE_CFLAGS_OPTIMIZE_* in qmake.conf, but it's too late, because QMAKE_CFLAGS_RELEASE is already set(i.e. -O2) so trying to add or remove QMAKE_CFLAGS_OPTIMIZE(that is reset now on) from QMAKE_CLAGS_RELEASE in common/features/default_post.prf won't work:

Quoted 15 lines
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
     }
}

This stuff is complicated...

Quoted 8 lines

So let's reset:
QMAKE_CFLAGS_RELEASE
QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG
in our qmake.conf.in since the only assignment done in mkspecs/common/gcc-base.conf only regards optimization.

Quoted 1 line

But that's a really elegant solution!

Thank you! It made me nut for days, not only for the solution itself but for writing commit log(as you can see below)! I think it's been the most difficult commit log I've ever written!

Quoted 20 lines
Quoted 20 lines

This package is also affected by BR2_TOOLCHAIN_HAS_GCC_BUG_90620 and it's been worked around by appending -O0 to CFLAGS/CXXFLAGS. This bug prevented workaround to work overriding optimization flags, so solving this also solves workaround problem.

Fixes:
http://autobuild.buildroot.net/results/ada/adaa9b4bcc6f9d2b5e82c479859a07e8abf5cf13/
http://autobuild.buildroot.net/results/a83/a83bdd1f3bf309c07abebe871b017c331ed36e67/

---
V1->V2:
* rewritten entire commit log
V2->V3:
* rewritten entire commit log again trying to explain better

---
  package/qt5/qt5base/qmake.conf.in | 4 ++++
  1 file changed, 4 insertions(+)
Quoted 8 lines

package/qt5/qt5base/qmake.conf.in QMAKE_CFLAGS_OPTIMIZE =

Quoted 5 lines
package/qt5/qt5base/qmake.conf.in +0 -0
index 2eb564e172..ae25b2e20f 100644
@@ -19,6 +19,10 @@ QMAKE_CFLAGS_OPTIMIZE       =

I've added a comment above "Remove all optimisation flags, we really only want
our own."

Yes, better to underline it.

Kind regards and thank you for reviewing this patch.

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 22 lines

Applied to master, thanks.

Regards,
Arnout

package/qt5/qt5base/qmake.conf.in QMAKE_CFLAGS_OPTIMIZE = · line 28

Quoted 11 lines
package/qt5/qt5base/qmake.conf.in +4 -0
  QMAKE_CFLAGS_OPTIMIZE_DEBUG =
  QMAKE_CFLAGS_OPTIMIZE_FULL  =
  QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
  CONFIG                 += nostrip
 
  QMAKE_LIBS             += -lrt -lpthread -ldl

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

PATCH v3 1/1 package/qt5base: fix building with correct optimization

In reply to Arnout Vandecappelle
Quoted 51 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 21 lines · Giulio Benetti

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 the same file, they use them to set
QMAKE_CFLAGS_RELEASE/QMAKE_CXXFLAGS_RELEASE:

QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE

At this point there is our chance to override QMAKE_CFLAGS_OPTIMIZE_* in qmake.conf, but it's too late, because QMAKE_CFLAGS_RELEASE is already set(i.e. -O2) so trying to add or remove QMAKE_CFLAGS_OPTIMIZE(that is reset now on) from QMAKE_CLAGS_RELEASE in common/features/default_post.prf won't work:

Quoted 15 lines

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
}
}

This stuff is complicated...

Quoted 8 lines

So let's reset:
QMAKE_CFLAGS_RELEASE
QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG
in our qmake.conf.in since the only assignment done in mkspecs/common/gcc-base.conf only regards optimization.

Quoted 1 line

But that's a really elegant solution!

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

Signature · 1 line
Bye, Peter Korsgaard