Skip to contentSkip to conversation

package/qt5webengine: fix compile flags for arm

PATCH In review Peter Seiderer 2 participants 6 messages Mar 6, 2020 – Jan 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 package/qt5webengine: fix compile flags for arm

The qt5webengine configure simple takes QT_ARCH ('arm') to determine the chromium compiler flags and uses some hard coded ARMv7 default values for the compiler command line: '... -march=armv7-a -mfloat-abi=hard -mtune=generic-armv7-a -mfpu=vfpv3-d16 ...'.

This results e.g. in an illegal instruction failure for rpi zero (reported on the mailing list, see [1]).

Disable all arm custom cpu flags (march/mfloat-abi/mtune/mfpu/mthumb) as these are already set by the compiler wrapper (via a patch to the chromium GN build system BUILD.gn file).

Despite the patch set all known values in the chromium GN build system config file chromium/build/config/arm.gni to not disturb the compile defines settings logic.

Fixes:

  $ /usr/lib/qt/examples/webengine/minimal/minimal
  Illegal instruction

[1] http://lists.busybox.net/pipermail/buildroot/2020-February/274587.html

---
Changes v1 -> v2:
- use new introduced BR2_GCC_TARGET_ARCH for arm_arch as the previous simple approach did not work (alternative would be to extract the arch at runtime via gcc invocation)

Changes v2 -> v3:
- disable all custom arm cpu flags (suggested by Thomas Petazzoni)

Notes:

- patches tested on top of the following two patches from

    Nathan Ford

    https://patchwork.ozlabs.org/patch/1246679/
    https://patchwork.ozlabs.org/patch/1246678/

- to prevent OOM compiled with reduced PARALLEL_JOBS via the following patch:

    --- a/package/qt5/qt5webengine/qt5webengine.mk
    +++ b/package/qt5/qt5webengine/qt5webengine.mk
    @@ -98,7 +98,8 @@ define QT5WEBENGINE_PYTHON2_SYMLINK
     endef
     QT5WEBENGINE_PRE_CONFIGURE_HOOKS += QT5WEBENGINE_PYTHON2_SYMLINK

    -QT5WEBENGINE_ENV += NINJAFLAGS="-j$(PARALLEL_JOBS)"
    +# limit to 2/3 PARALLEL_JOBS to prevent OOM situation
    +QT5WEBENGINE_ENV += NINJAFLAGS="-j$(shell echo $(PARALLEL_JOBS)*2/3+1 | bc )"

     ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y)
     define QT5WEBENGINE_CREATE_HOST_PKG_CONFIG

- to check the compiler inokations enabeld ninja verbose mode via the

    following patch:

    --- a/package/qt5/qt5webengine/qt5webengine.mk
    +++ b/package/qt5/qt5webengine/qt5webengine.mk
    @@ -99,7 +99,7 @@ endef
     QT5WEBENGINE_PRE_CONFIGURE_HOOKS += QT5WEBENGINE_PYTHON2_SYMLINK

     # limit to 2/3 PARALLEL_JOBS to prevent OOM situation
    -QT5WEBENGINE_ENV += NINJAFLAGS="-j$(shell echo $(PARALLEL_JOBS)*2/3+1 | bc )"
    +QT5WEBENGINE_ENV += NINJAFLAGS="-v -j$(shell echo $(PARALLEL_JOBS)*2/3+1 | bc )"

     ifeq ($(BR2_PACKAGE_QT5_VERSION_LATEST),y)
     define QT5WEBENGINE_CREATE_HOST_PKG_CONFIG
---
 ...n-disable-all-custom-arm-cpu-compile.patch | 79 +++++++++++++++++++
 package/qt5/qt5webengine/qt5webengine.mk      | 69 ++++++++++++++++
 2 files changed, 148 insertions(+)
 create mode 100644 package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch
package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch new file +79 -0
new file mode 100644
index 0000000000..e69ce40696
@@ -0,0 +1,79 @@
+From 51e83c5619cedecabcce41f9d2a1e0016ea72e00 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <[email protected]>
+Date: Mon, 2 Mar 2020 21:29:58 +0100
+Subject: [PATCH] chromium/BUILD.gn: disable all custom arm cpu compiler flags
+
+Disable all custom arm cpu compiler flags as these are already set
+by the buildroot compiler wrapper:
+
+  - march
+  - mfloat-abi
+  - mtune
+  - mfpu
+  - mthumb
+
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ .../chromium/build/config/compiler/BUILD.gn   | 23 ++++++++++++-------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+diff --git a/src/3rdparty/chromium/build/config/compiler/BUILD.gn b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+index d223a4f6f..16dec5c6a 100644
+--- a/src/3rdparty/chromium/build/config/compiler/BUILD.gn
++++ b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+@@ -672,7 +672,8 @@ config("compiler") {
+     # TODO(pcc): The contents of .ARM.attributes should be based on the
+     # -march flag passed at compile time (see llvm.org/pr36291).
+     if (current_cpu == "arm") {
+-      ldflags += [ "-march=$arm_arch" ]
++      # disabled for the buildroot compile
++      # ldflags += [ "-march=$arm_arch" ]
+     }
+   }
+ 
+@@ -752,13 +753,15 @@ config("compiler_cpu_abi") {
+         ldflags += [ "--target=arm-linux-gnueabihf" ]
+       }
+       if (!is_nacl) {
+-        cflags += [
+-          "-march=$arm_arch",
+-          "-mfloat-abi=$arm_float_abi",
+-        ]
++        # disabled for the buildroot compile
++        # cflags += [
++        #   "-march=$arm_arch",
++        #   "-mfloat-abi=$arm_float_abi",
++        # ]
+       }
+       if (arm_tune != "") {
+-        cflags += [ "-mtune=$arm_tune" ]
++        # disabled for the buildroot compile
++        # cflags += [ "-mtune=$arm_tune" ]
+       }
+     } else if (current_cpu == "arm64") {
+       if (is_clang && !is_android && !is_nacl && !is_fuchsia) {
+@@ -1130,7 +1133,9 @@ config("clang_revision") {
+ 
+ config("compiler_arm_fpu") {
+   if (current_cpu == "arm" && !is_ios && !is_nacl) {
+-    cflags = [ "-mfpu=$arm_fpu" ]
++    # disabled for the buildroot compile
++    # cflags = [ "-mfpu=$arm_fpu" ]
++    cflags = []
+     asmflags = cflags
+   }
+ }
+@@ -1138,7 +1143,9 @@ config("compiler_arm_fpu") {
+ config("compiler_arm_thumb") {
+   if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+       !(is_mac || is_ios || is_nacl)) {
+-    cflags = [ "-mthumb" ]
++    # disabled for the buildroot compile
++    # cflags = [ "-mthumb" ]
++    cflags = []
+     if (is_android && !is_clang) {
+       # Clang doesn't support this option.
+       cflags += [ "-mthumb-interwork" ]
+-- 
+2.25.1
+
package/qt5/qt5webengine/qt5webengine.mk +69 -0

76 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 2/2 package/qt5webengine: use buildroot cflags/ldflags for arm

---
Changes v2 -> v3:
- new patch

Notes:
- optional patch, maybe the whole setting of the additional buildroot cflags/ldflags is to much?

Example command line without this additional patch:

.../host/bin/arm-buildroot-linux-gnueabihf-g++ -MMD -MF obj/base/base/base_jumbo_4.o.d -DUSE_SYMBOLIZE -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_NSS_CERTS=1 -DUSE_OZONE=1 -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DOFFICIAL_BUILD -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DTOOLKIT_QT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCR_SYSROOT_HASH=b2165ab47ab9c4cc780db53ace1b08607d68ae31 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -I. -Igen -I../../3rdparty/chromium -Igen -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pipe -pthread -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wno-psabi -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-deprecated-declarations -fno-delete-null-pointer-checks -Wno-comments -Wno-dangling-else -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-unused-parameter -fno-omit-frame-pointer -g0 -fvisibility=hidden -O2 -fno-ident -fdata-sections -ffunction-sections -std=gnu++14 -Wno-narrowing -Wno-attributes -Wno-class-memaccess -Wno-subobject-linkage -fno-exceptions -fno-rtti --sysroot=../../../../../host/arm-buildroot-linux-gnueabihf/sysroot -fvisibility-inlines-hidden -c gen/base/base_jumbo_4.cc -o obj/base/base/base_jumbo_4.o

Example command line with this additional patch:

.../host/bin/arm-buildroot-linux-gnueabihf-g++ -MMD -MF obj/base/base/base_jumbo_4.o.d -DUSE_SYMBOLIZE -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_NSS_CERTS=1 -DUSE_OZONE=1 -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DOFFICIAL_BUILD -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DTOOLKIT_QT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCR_SYSROOT_HASH=b2165ab47ab9c4cc780db53ace1b08607d68ae31 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -I. -Igen -I../../3rdparty/chromium -Igen -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pipe -pthread -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O3 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wno-psabi -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-deprecated-declarations -fno-delete-null-pointer-checks -Wno-comments -Wno-dangling-else -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-unused-parameter -fno-omit-frame-pointer -g0 -fvisibility=hidden -O2 -fno-ident -fdata-sections -ffunction-sections -std=gnu++14 -Wno-narrowing -Wno-attributes -Wno-class-memaccess -Wno-subobject-linkage -fno-exceptions -fno-rtti --sysroot=../../../../../host/arm-buildroot-linux-gnueabihf/sysroot -fvisibility-inlines-hidden -c gen/base/base_jumbo_4.cc -o obj/base/base/base_jumbo_4.o

---
 ...n-use-buildroot-provided-cflags-ldfl.patch | 42 +++++++++++++++++++
 package/qt5/qt5webengine/qt5webengine.mk      |  6 +++
 2 files changed, 48 insertions(+)
 create mode 100644 package/qt5/qt5webengine/5.12.7/0003-chromium-BUILD.gn-use-buildroot-provided-cflags-ldfl.patch
package/qt5/qt5webengine/5.12.7/0003-chromium-BUILD.gn-use-buildroot-provided-cflags-ldfl.patch new file +42 -0
new file mode 100644
index 0000000000..52ddc2d878
@@ -0,0 +1,42 @@
+From f647383e9af9896a7a0247d20b3db480c14863f3 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <[email protected]>
+Date: Fri, 6 Mar 2020 18:55:02 +0100
+Subject: [PATCH] chromium/BUILD.gn: use buildroot provided cflags/ldflags
+
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ src/3rdparty/chromium/build/config/compiler/BUILD.gn | 11 ++++-------
+ 1 file changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/src/3rdparty/chromium/build/config/compiler/BUILD.gn b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+index 16dec5c6a..e2c5982f5 100644
+--- a/src/3rdparty/chromium/build/config/compiler/BUILD.gn
++++ b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+@@ -672,8 +672,8 @@ config("compiler") {
+     # TODO(pcc): The contents of .ARM.attributes should be based on the
+     # -march flag passed at compile time (see llvm.org/pr36291).
+     if (current_cpu == "arm") {
+-      # disabled for the buildroot compile
+-      # ldflags += [ "-march=$arm_arch" ]
++      # will be set by  buildroot
++      ldflags += [ @TARGET_LDFLAGS@ ]
+     }
+   }
+ 
+@@ -753,11 +753,8 @@ config("compiler_cpu_abi") {
+         ldflags += [ "--target=arm-linux-gnueabihf" ]
+       }
+       if (!is_nacl) {
+-        # disabled for the buildroot compile
+-        # cflags += [
+-        #   "-march=$arm_arch",
+-        #   "-mfloat-abi=$arm_float_abi",
+-        # ]
++        # will be set by buildroot
++        cflags += [ @TARGET_CXXFLAGS@ ]
+       }
+       if (arm_tune != "") {
+         # disabled for the buildroot compile
+-- 
+2.25.1
+
package/qt5/qt5webengine/qt5webengine.mk +6 -0
index 7337b67e9d..a60a19df88 100644
@@ -169,6 +169,11 @@ define QT5WEBENGINE_CONFIGURE_ARM_THUMB
 	$(SED) 's/^    arm_use_thumb = true$$/    arm_use_thumb = false/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
 endef
 endif
+
+define QT5WEBENGINE_CONFIGURE_COMPILER_FLAGS
+	$(SED) 's%@TARGET_CXXFLAGS@%$(call make-comma-list,$(TARGET_CXXFLAGS))%g' $(@D)/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+	$(SED) 's%@TARGET_LDFLAGS@%$(call make-comma-list,$(TARGET_LDFLAGS))%g' $(@D)/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+endef
 endif
 
 define QT5WEBENGINE_CONFIGURE_CMDS
@@ -179,6 +184,7 @@ define QT5WEBENGINE_CONFIGURE_CMDS
 	$(QT5WEBENGINE_CONFIGURE_ARM_TUNE)
 	$(QT5WEBENGINE_CONFIGURE_ARM_NEON)
 	$(QT5WEBENGINE_CONFIGURE_ARM_THUMB)
+	$(QT5WEBENGINE_CONFIGURE_COMPILER_FLAGS)
 	(cd $(@D); $(TARGET_MAKE_ENV) $(QT5WEBENGINE_ENV) $(HOST_DIR)/bin/qmake $(QT5WEBENGINE_QMAKEFLAGS))
 endef
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [Buildroot] [PATCH v3 2/2] package/qt5webengine: use buildroot cflags/ldflags for arm

package/qt5/qt5webengine/qt5webengine.mk define QT5WEBENGINE_CONFIGURE_ARM_THUMB · line 176

Quoted 4 lines · On Fri, 6 Mar 2020 21:34:10 +0100 Peter Seiderer <[email protected]> wrote:
package/qt5/qt5webengine/qt5webengine.mk +4 -0
+define QT5WEBENGINE_CONFIGURE_COMPILER_FLAGS
+	$(SED) 's%@TARGET_CXXFLAGS@%$(call make-comma-list,$(TARGET_CXXFLAGS))%g' $(@D)/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+	$(SED) 's%@TARGET_LDFLAGS@%$(call make-comma-list,$(TARGET_LDFLAGS))%g' $(@D)/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+endef

This looks like a good thing. Could it replace the ARM-specific logic you had in your PATCH 1/2 ?

Thomas

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

Re: [Buildroot] [PATCH v3 2/2] package/qt5webengine: use buildroot cflags/ldflags for arm

Hello Thomas,

Quoted 10 lines · Thomas Petazzoni

package/qt5/qt5webengine/qt5webengine.mk define QT5WEBENGINE_CONFIGURE_ARM_THUMB · line 176

Quoted 4 lines · On Fri, 6 Mar 2020 21:34:10 +0100 Peter Seiderer <[email protected]> wrote:
package/qt5/qt5webengine/qt5webengine.mk +4 -0
+define QT5WEBENGINE_CONFIGURE_COMPILER_FLAGS
+	$(SED) 's%@TARGET_CXXFLAGS@%$(call make-comma-list,$(TARGET_CXXFLAGS))%g' $(@D)/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+	$(SED) 's%@TARGET_LDFLAGS@%$(call make-comma-list,$(TARGET_LDFLAGS))%g' $(@D)/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+endef

This looks like a good thing. Could it replace the ARM-specific logic you had in your PATCH 1/2 ?

Not sure as there is more optional and/or compile defines logic depending on the various arm-options logic..., the save way seems to be the right setting of the various arm-options (but did not find a better way as to edit/sed the GN files...

Regards,
Peter

Quoted 2 lines

Thomas

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
In reply to Peter Seiderer

Hello Peter,

Quoted 8 lines · On Fri, 6 Mar 2020 21:34:09 +0100 Peter Seiderer <[email protected]> wrote:

The qt5webengine configure simple takes QT_ARCH ('arm') to determine the chromium compiler flags and uses some hard coded ARMv7 default values for the compiler command line: '... -march=armv7-a -mfloat-abi=hard -mtune=generic-armv7-a -mfpu=vfpv3-d16 ...'.

This results e.g. in an illegal instruction failure for rpi zero (reported on the mailing list, see [1]).

Quoted 7 lines

Disable all arm custom cpu flags (march/mfloat-abi/mtune/mfpu/mthumb) as these are already set by the compiler wrapper (via a patch to the chromium GN build system BUILD.gn file).

Despite the patch set all known values in the chromium GN build system config file chromium/build/config/arm.gni to not disturb the compile defines settings logic.

It's been a very long time since this patch was posted. Does the problem still occur? There is a patch series from James Hilliard upgrading qt5webengine:

https://patchwork.ozlabs.org/project/buildroot/list/?series=279766

Some more questions below.

Quoted 47 lines
package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch new file +47 -0
+diff --git a/src/3rdparty/chromium/build/config/compiler/BUILD.gn b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+index d223a4f6f..16dec5c6a 100644
+--- a/src/3rdparty/chromium/build/config/compiler/BUILD.gn
++++ b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+@@ -672,7 +672,8 @@ config("compiler") {
+     # TODO(pcc): The contents of .ARM.attributes should be based on the
+     # -march flag passed at compile time (see llvm.org/pr36291).
+     if (current_cpu == "arm") {
+-      ldflags += [ "-march=$arm_arch" ]
++      # disabled for the buildroot compile
++      # ldflags += [ "-march=$arm_arch" ]
+     }
+   }
+ 
+@@ -752,13 +753,15 @@ config("compiler_cpu_abi") {
+         ldflags += [ "--target=arm-linux-gnueabihf" ]
+       }
+       if (!is_nacl) {
+-        cflags += [
+-          "-march=$arm_arch",
+-          "-mfloat-abi=$arm_float_abi",
+-        ]
++        # disabled for the buildroot compile
++        # cflags += [
++        #   "-march=$arm_arch",
++        #   "-mfloat-abi=$arm_float_abi",
++        # ]
+       }
+       if (arm_tune != "") {
+-        cflags += [ "-mtune=$arm_tune" ]
++        # disabled for the buildroot compile
++        # cflags += [ "-mtune=$arm_tune" ]
+       }
+     } else if (current_cpu == "arm64") {
+       if (is_clang && !is_android && !is_nacl && !is_fuchsia) {
+@@ -1130,7 +1133,9 @@ config("clang_revision") {
+ 
+ config("compiler_arm_fpu") {
+   if (current_cpu == "arm" && !is_ios && !is_nacl) {
+-    cflags = [ "-mfpu=$arm_fpu" ]
++    # disabled for the buildroot compile
++    # cflags = [ "-mfpu=$arm_fpu" ]
++    cflags = []
+     asmflags = cflags
+   }
+ }
+@@ -1138,7 +1143,9 @@ config("compiler_arm_fpu") {

package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch line 76

Quoted 10 lines
package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch new file +10 -0
+ config("compiler_arm_thumb") {
+   if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+       !(is_mac || is_ios || is_nacl)) {
+-    cflags = [ "-mthumb" ]
++    # disabled for the buildroot compile
++    # cflags = [ "-mthumb" ]
++    cflags = []
+     if (is_android && !is_clang) {
+       # Clang doesn't support this option.
+       cflags += [ "-mthumb-interwork" ]

You're fixing the problem for ARM, but is there some similar mess for other CPU architectures?

Quoted 51 lines
package/qt5/qt5webengine/qt5webengine.mk +51 -0
+# configure arm architecture paramter for chromium compile
+ifeq ($(BR2_arm),y)
+ifeq ($(BR2_ARM_CPU_ARMV4),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 4/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+ifeq ($(BR2_ARM_CPU_ARMV5),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 5/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+ifeq ($(BR2_ARM_CPU_ARMV6),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 6/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+# no entriy for BR2_ARM_CPU_ARMV7A/BR2_ARM_CPU_ARMV7M, arm_vesion = 7 is already set by default
+
+ifeq ($(BR2_ARM_CPU_ARMV8A),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 8/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+# not known by buildroot, set to some dummy to disable all default logic
+define QT5WEBENGINE_CONFIGURE_ARM_ARCH
+	$(SED) 's/^    arm_arch = ""$$/    arm_arch = "arm-dummy-arch"/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+define QT5WEBENGINE_CONFIGURE_ARM_FPU
+	$(SED) 's/^    arm_fpu = ""$$/    arm_fpu = $(BR2_GCC_TARGET_FPU)/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+define QT5WEBENGINE_CONFIGURE_ARM_FLOAT_ABI
+	$(SED) 's/^    arm_float_abi = ""$$/    arm_float_abi = $(BR2_GCC_TARGET_FLOAT_ABI)/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+define QT5WEBENGINE_CONFIGURE_ARM_TUNE
+	$(SED) 's/^    arm_tune = ""$$/    arm_tune = $(BR2_GCC_TARGET_CPU)/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+ifeq ($(BR2_ARM_CPU_HAS_NEON),y)
+define QT5WEBENGINE_CONFIGURE_ARM_NEON
+	$(SED) 's/^    arm_use_neon = ""$$/    arm_use_neon = "true"/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+else
+define QT5WEBENGINE_CONFIGURE_ARM_NEON

package/qt5/qt5webengine/qt5webengine.mk QT5WEBENGINE_PRE_CONFIGURE_HOOKS += QT5WEBENGINE_CREATE_HOST_PKG_CONFIG · line 172

Quoted 10 lines
package/qt5/qt5webengine/qt5webengine.mk +10 -0
+	$(SED) 's/^    arm_use_neon = ""$$/    arm_use_neon = "false"/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+ifeq ($(BR2_ARM_CPU_HAS_THUMB),)
+define QT5WEBENGINE_CONFIGURE_ARM_THUMB
+	$(SED) 's/^    arm_use_thumb = true$$/    arm_use_thumb = false/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+endif

What are all those variables doing in the GN Chromium stuff?

I'm kind of worried by two aspects:

- This is all very ARM specific, but we have other CPU architectures supported in Buildroot

- We already pass the proper CFLAGS, so it's always annoying to duplicate this logic into package-specific flags

Thomas

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

Hello Thomas,

Quoted 21 lines · Thomas Petazzoni

Hello Peter,

Quoted 8 lines · On Fri, 6 Mar 2020 21:34:09 +0100 Peter Seiderer <[email protected]> wrote:

The qt5webengine configure simple takes QT_ARCH ('arm') to determine the chromium compiler flags and uses some hard coded ARMv7 default values for the compiler command line: '... -march=armv7-a -mfloat-abi=hard -mtune=generic-armv7-a -mfpu=vfpv3-d16 ...'.

This results e.g. in an illegal instruction failure for rpi zero (reported on the mailing list, see [1]).

Quoted 7 lines

Disable all arm custom cpu flags (march/mfloat-abi/mtune/mfpu/mthumb) as these are already set by the compiler wrapper (via a patch to the chromium GN build system BUILD.gn file).

Despite the patch set all known values in the chromium GN build system config file chromium/build/config/arm.gni to not disturb the compile defines settings logic.

Quoted 5 lines

It's been a very long time since this patch was posted. Does the problem still occur? There is a patch series from James Hilliard upgrading qt5webengine:

https://patchwork.ozlabs.org/project/buildroot/list/?series=279766

Problem still exits with qt5webengine-5.15.2 and qt5webengine-5.15.8...

Quoted 119 lines

Some more questions below.

Quoted 47 lines
package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch new file +47 -0
+diff --git a/src/3rdparty/chromium/build/config/compiler/BUILD.gn b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+index d223a4f6f..16dec5c6a 100644
+--- a/src/3rdparty/chromium/build/config/compiler/BUILD.gn
++++ b/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+@@ -672,7 +672,8 @@ config("compiler") {
+     # TODO(pcc): The contents of .ARM.attributes should be based on the
+     # -march flag passed at compile time (see llvm.org/pr36291).
+     if (current_cpu == "arm") {
+-      ldflags += [ "-march=$arm_arch" ]
++      # disabled for the buildroot compile
++      # ldflags += [ "-march=$arm_arch" ]
+     }
+   }
+
+@@ -752,13 +753,15 @@ config("compiler_cpu_abi") {
+         ldflags += [ "--target=arm-linux-gnueabihf" ]
+       }
+       if (!is_nacl) {
+-        cflags += [
+-          "-march=$arm_arch",
+-          "-mfloat-abi=$arm_float_abi",
+-        ]
++        # disabled for the buildroot compile
++        # cflags += [
++        #   "-march=$arm_arch",
++        #   "-mfloat-abi=$arm_float_abi",
++        # ]
+       }
+       if (arm_tune != "") {
+-        cflags += [ "-mtune=$arm_tune" ]
++        # disabled for the buildroot compile
++        # cflags += [ "-mtune=$arm_tune" ]
+       }
+     } else if (current_cpu == "arm64") {
+       if (is_clang && !is_android && !is_nacl && !is_fuchsia) {
+@@ -1130,7 +1133,9 @@ config("clang_revision") {
+
+ config("compiler_arm_fpu") {
+   if (current_cpu == "arm" && !is_ios && !is_nacl) {
+-    cflags = [ "-mfpu=$arm_fpu" ]
++    # disabled for the buildroot compile
++    # cflags = [ "-mfpu=$arm_fpu" ]
++    cflags = []
+     asmflags = cflags
+   }
+ }
+@@ -1138,7 +1143,9 @@ config("compiler_arm_fpu") {

package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch line 76

Quoted 10 lines
package/qt5/qt5webengine/5.12.7/0002-chromium-BUILD.gn-disable-all-custom-arm-cpu-compile.patch new file +10 -0
+ config("compiler_arm_thumb") {
+   if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+       !(is_mac || is_ios || is_nacl)) {
+-    cflags = [ "-mthumb" ]
++    # disabled for the buildroot compile
++    # cflags = [ "-mthumb" ]
++    cflags = []
+     if (is_android && !is_clang) {
+       # Clang doesn't support this option.
+       cflags += [ "-mthumb-interwork" ]

You're fixing the problem for ARM, but is there some similar mess for other CPU architectures?

Quoted 55 lines
package/qt5/qt5webengine/qt5webengine.mk +55 -0
+# configure arm architecture paramter for chromium compile
+ifeq ($(BR2_arm),y)
+ifeq ($(BR2_ARM_CPU_ARMV4),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 4/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+ifeq ($(BR2_ARM_CPU_ARMV5),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 5/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+ifeq ($(BR2_ARM_CPU_ARMV6),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 6/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+# no entriy for BR2_ARM_CPU_ARMV7A/BR2_ARM_CPU_ARMV7M, arm_vesion = 7 is already set by default
+
+ifeq ($(BR2_ARM_CPU_ARMV8A),y)
+define QT5WEBENGINE_CONFIGURE_ARM_VERSION
+	$(SED) 's/^    arm_version = 7$$/    arm_version = 8/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
+# not known by buildroot, set to some dummy to disable all default logic
+define QT5WEBENGINE_CONFIGURE_ARM_ARCH
+	$(SED) 's/^    arm_arch = ""$$/    arm_arch = "arm-dummy-arch"/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+define QT5WEBENGINE_CONFIGURE_ARM_FPU
+	$(SED) 's/^    arm_fpu = ""$$/    arm_fpu = $(BR2_GCC_TARGET_FPU)/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+define QT5WEBENGINE_CONFIGURE_ARM_FLOAT_ABI
+	$(SED) 's/^    arm_float_abi = ""$$/    arm_float_abi = $(BR2_GCC_TARGET_FLOAT_ABI)/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+define QT5WEBENGINE_CONFIGURE_ARM_TUNE
+	$(SED) 's/^    arm_tune = ""$$/    arm_tune = $(BR2_GCC_TARGET_CPU)/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+
+ifeq ($(BR2_ARM_CPU_HAS_NEON),y)
+define QT5WEBENGINE_CONFIGURE_ARM_NEON
+	$(SED) 's/^    arm_use_neon = ""$$/    arm_use_neon = "true"/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+else
+define QT5WEBENGINE_CONFIGURE_ARM_NEON
+	$(SED) 's/^    arm_use_neon = ""$$/    arm_use_neon = "false"/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+
Quoted 8 lines

package/qt5/qt5webengine/qt5webengine.mk QT5WEBENGINE_PRE_CONFIGURE_HOOKS += QT5WEBENGINE_CREATE_HOST_PKG_CONFIG · line 172

Quoted 6 lines
package/qt5/qt5webengine/qt5webengine.mk +6 -0
+ifeq ($(BR2_ARM_CPU_HAS_THUMB),)
+define QT5WEBENGINE_CONFIGURE_ARM_THUMB
+	$(SED) 's/^    arm_use_thumb = true$$/    arm_use_thumb = false/' $(@D)/src/3rdparty/chromium/build/config/arm.gni
+endef
+endif
+endif

What are all those variables doing in the GN Chromium stuff?

Setting compiler flags e.g.

	arm_use_thumb --> -mthumb
	arm_use_neon  --> -DUSE_NEON and influences arm_fpu setting (if not already set)...
Quoted 5 lines

I'm kind of worried by two aspects:

- This is all very ARM specific, but we have other CPU architectures supported in Buildroot

Yes there is a although some x86/x64 logic setting e.g. -m32/-m64 and -msse2/-mfpmath=sse/-mmmx and some mips/ppc/s390 and more..., but did only take a deeper look at the arm part as the reported failure was about rpi-zero...

Quoted 3 lines

- We already pass the proper CFLAGS, so it's always annoying to duplicate this logic into package-specific flags

Yes... ;-)

Regards,
Peter

Quoted 2 lines

Thomas

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot