All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [RFC 0/2] configs: raspberrypi3: fix mismatch cpu arch
@ 2017-04-16 15:14 Gaël PORTAY
  2017-04-16 15:14 ` [Buildroot] [RFC 1/2] " Gaël PORTAY
  2017-04-16 15:14 ` [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target Gaël PORTAY
  0 siblings, 2 replies; 9+ messages in thread
From: Gaël PORTAY @ 2017-04-16 15:14 UTC (permalink / raw)
  To: buildroot

Hi all,

The RaspberryPi 3 is powered by a Broadcom BCM2837 which is a 64bits Cortex-A53
ARM processor (armv8).

Currently, BR defines the RPI3 as a simple Cortex-A7 (armv7), which is fair
enough.

The first patch updates the ARM architecture to Cortex-A53 (BR2_cortex_a53=y)
but leave the same 32 bit-length architecture (BR2_arm=y).

BR was compiling and the RPI3 was running fine until I decided to compile
qt5base.

At this stage, GCC (6.3) complains about an unknown attribute:

	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
	 static uint crc32(const Char *ptr, size_t len, uint h)

According to GCC, the +crc attribute is specific to armv8/AArch64 [1].

Also, according to the ARM (R) C Language Extensions Release 2.0 pdf [2].

	6.5.8 CRC32 Extension
	__ARM_FEATURE_CRC32 is defined to 1 if the CRC32 instructions are
	supported and the intrinsics defined in 9.7 are available. These
	instructions include CRC32B, CRC32H etc. This is only available when
	__ARM_ARCH >= 8

	9.7 CRC32 intrinsics
	CRC32 intrinsics provide direct access to CRC32 instructions
	CRC32{C}{B, H, W, X} in both ARMv8 AArch32 and AArch64 execution states.
	These intrinsics are available when __ARM_FEATURE_CRC32 is defined.

Here is the list of the ARM defines generated by the BR toolchain (w/ BR2_arm=y
and BR2_cortex_a53=y).

	#define __arm__ 1
	#define __ARM_32BIT_STATE 1
	#define __ARM_ARCH 8
	#define __ARM_ARCH_8A__ 1
	#define __ARM_ARCH_EXT_IDIV__ 1
	#define __ARM_ARCH_ISA_ARM 1
	#define __ARM_ARCH_ISA_THUMB 2
	#define __ARM_ARCH_PROFILE 65
	#define __ARM_EABI__ 1
	#define __ARMEL__ 1
	#define __ARM_FEATURE_CLZ 1
	#define __ARM_FEATURE_CRC32 1
	#define __ARM_FEATURE_DSP 1
	#define __ARM_FEATURE_IDIV 1
	#define __ARM_FEATURE_LDREX 15
	#define __ARM_FEATURE_QBIT 1
	#define __ARM_FEATURE_SAT 1
	#define __ARM_FEATURE_SIMD32 1
	#define __ARM_FEATURE_UNALIGNED 1
	#define __ARM_PCS 1
	#define __ARM_SIZEOF_MINIMAL_ENUM 4
	#define __ARM_SIZEOF_WCHAR_T 4

Toolchain seems to be a 32bits (presence of __ARM_32BIT_STATE) and for armv8-a
target (__ARM_ARCH 8, __ARM_ARCH_8A__...).

Because of #define __ARM_FEATURE_CRC32 1, qt5base does not compile (due to the
attribute target=+crc) [3].

Note: If I remove the attribute(target=+crc), the compilation fails at linkage
saying crc32 instructions are bad.

When I force architecture to armv7 (ie. -march=armv7), __ARM_FEATURE_CRC32 is
unset. I assume it compiles.

My understanding is that the crc32 instructions are not available in 32bits
mode.

In this RFC, the second patch tries to fix qt5base. It checks for both defines

        #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)

Instead of checking the single define __ARM_FEATURE_CRC32.

I guess my fix is not appropriate. Anyone can tell me what exactly is wrong in
there?
- Maybe I make a confusion between __ARM_32BIT_STATE and AArch32.
- Maybe the toolchain is not properly set using arm/cortex_a53.
- Maybe the points 6.5.8 and 9.7 from [2] are not true.

[1] https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#g_t-march-and--mcpu-Feature-Modifiers
[2] http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf
[3] https://github.com/qt/qtbase/blob/5.8/src/corelib/tools/qhash.cpp#L140

Regards,
Ga?l PORTAY (2):
  configs: raspberrypi3: fix mismatch cpu arch
  qt5base: fix build failure with a 32bit armv8

 configs/raspberrypi3_defconfig                     |  2 +-
 ...01-Fix-ARM32-CRC-build-issue-on-armv8-cpu.patch | 90 ++++++++++++++++++++++
 ...01-Fix-ARM32-CRC-build-issue-on-armv8-cpu.patch |  1 +
 3 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 package/qt5/qt5base/5.6.2/0001-Fix-ARM32-CRC-build-issue-on-armv8-cpu.patch
 create mode 120000 package/qt5/qt5base/5.8.0/0001-Fix-ARM32-CRC-build-issue-on-armv8-cpu.patch

PS: Here is the list of the ARM defines if I force -march=armv7.

	#define __arm__ 1
	#define __ARM_32BIT_STATE 1
	#define __ARM_ARCH 7
	#define __ARM_ARCH_7A__ 1
	#define __ARM_ARCH_ISA_ARM 1
	#define __ARM_ARCH_ISA_THUMB 2
	#define __ARM_ARCH_PROFILE 65
	#define __ARM_EABI__ 1
	#define __ARMEL__ 1
	#define __ARM_FEATURE_CLZ 1
	#define __ARM_FEATURE_DSP 1
	#define __ARM_FEATURE_LDREX 15
	#define __ARM_FEATURE_QBIT 1
	#define __ARM_FEATURE_SAT 1
	#define __ARM_FEATURE_SIMD32 1
	#define __ARM_FEATURE_UNALIGNED 1
	#define __ARM_PCS 1
	#define __ARM_SIZEOF_MINIMAL_ENUM 4
	#define __ARM_SIZEOF_WCHAR_T 4

-- 
2.12.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 1/2] configs: raspberrypi3: fix mismatch cpu arch
  2017-04-16 15:14 [Buildroot] [RFC 0/2] configs: raspberrypi3: fix mismatch cpu arch Gaël PORTAY
@ 2017-04-16 15:14 ` Gaël PORTAY
  2017-04-18 20:15   ` Arnout Vandecappelle
                     ` (2 more replies)
  2017-04-16 15:14 ` [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target Gaël PORTAY
  1 sibling, 3 replies; 9+ messages in thread
From: Gaël PORTAY @ 2017-04-16 15:14 UTC (permalink / raw)
  To: buildroot

The raspberrypi3 is powered by a Broadcom BCM2837 which is a Cortex-A53.

Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
---
 configs/raspberrypi3_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig
index 1b2134e0b..3d8949765 100644
--- a/configs/raspberrypi3_defconfig
+++ b/configs/raspberrypi3_defconfig
@@ -1,5 +1,5 @@
 BR2_arm=y
-BR2_cortex_a7=y
+BR2_cortex_a53=y
 BR2_ARM_EABIHF=y
 BR2_ARM_FPU_NEON_VFPV4=y
 
-- 
2.12.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target
  2017-04-16 15:14 [Buildroot] [RFC 0/2] configs: raspberrypi3: fix mismatch cpu arch Gaël PORTAY
  2017-04-16 15:14 ` [Buildroot] [RFC 1/2] " Gaël PORTAY
@ 2017-04-16 15:14 ` Gaël PORTAY
  2017-04-18 21:32   ` Arnout Vandecappelle
  1 sibling, 1 reply; 9+ messages in thread
From: Gaël PORTAY @ 2017-04-16 15:14 UTC (permalink / raw)
  To: buildroot

__ARM_FEATURE_CRC32 macro is set for armv8 cpus.

In case of a 32bits armv8 target, gcc complains about an unknown
attribute +crc.

	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
	 static uint crc32(const Char *ptr, size_t len, uint h)

This attribute looks to not be available in 32bits mode. If the
attribute is bypassed (commented), the build breaks at linkage saying
crc32x instructions are bad.

To solve this build issue, this patch checks for both __aarch64__ and
__ARM_FEATURE_CRC32.

Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
---
 ...ix-CRC-build-issue-on-32bits-armv8-target.patch | 95 ++++++++++++++++++++++
 ...ix-CRC-build-issue-on-32bits-armv8-target.patch |  1 +
 2 files changed, 96 insertions(+)
 create mode 100644 package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
 create mode 120000 package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch

diff --git a/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch b/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
new file mode 100644
index 000000000..a648ea04d
--- /dev/null
+++ b/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
@@ -0,0 +1,95 @@
+From 0382127e9f39f83e313ea279bc407d4eb6bd5e73 Mon Sep 17 00:00:00 2001
+From: =?utf-8?q?Ga=C3=ABl=20PORTAY?= <gael.portay@savoirfairelinux.com>
+Date: Tue, 11 Apr 2017 17:28:48 -0400
+Subject: [PATCH] Fix CRC build issue on 32bits armv8 target
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 8bit
+
+__ARM_FEATURE_CRC32 macro is set for armv8 cpus.
+
+In case of a 32bits armv8 target, gcc complains about an unknown
+attribute +crc.
+
+	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
+	 static uint crc32(const Char *ptr, size_t len, uint h)
+
+This attribute looks to not be available in 32bits mode. If the
+attribute is bypassed (commented), the build breaks at linkage saying
+crc32x instructions are bad.
+
+To solve this build issue, this patch checks for both __aarch64__ and
+__ARM_FEATURE_CRC32.
+
+Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
+---
+ config.tests/arch/arch.cpp  | 2 +-
+ src/corelib/tools/qhash.cpp | 2 +-
+ src/corelib/tools/qsimd.cpp | 2 +-
+ src/corelib/tools/qsimd_p.h | 4 ++--
+ 4 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/config.tests/arch/arch.cpp b/config.tests/arch/arch.cpp
+index f99c5ca118..72f4af39fe 100644
+--- a/config.tests/arch/arch.cpp
++++ b/config.tests/arch/arch.cpp
+@@ -249,7 +249,7 @@ const char msg2[] = "==Qt=magic=Qt== Sub-architecture:"
+ #ifdef __IWMMXT__
+ " iwmmxt"
+ #endif
+-#ifdef __ARM_FEATURE_CRC32
++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
+ " crc32"
+ #endif
+ 
+diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
+index abec9ebb79..84cbe51731 100644
+--- a/src/corelib/tools/qhash.cpp
++++ b/src/corelib/tools/qhash.cpp
+@@ -137,7 +137,7 @@ static uint crc32(const Char *ptr, size_t len, uint h)
+         h = _mm_crc32_u8(h, *p);
+     return h;
+ }
+-#elif defined(__ARM_FEATURE_CRC32)
++#elif defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
+ static inline bool hasFastCrc32()
+ {
+     return qCpuHasFeature(CRC32);
+diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
+index d4edf459de..f07cb2914a 100644
+--- a/src/corelib/tools/qsimd.cpp
++++ b/src/corelib/tools/qsimd.cpp
+@@ -136,7 +136,7 @@ static inline quint64 detectProcessorFeatures()
+ #if defined(__ARM_NEON__)
+     features |= Q_UINT64_C(1) << CpuFeatureNEON;
+ #endif
+-#if defined(__ARM_FEATURE_CRC32)
++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
+     features |= Q_UINT64_C(1) << CpuFeatureCRC32;
+ #endif
+ 
+diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
+index d5d887598e..92c93ea2e7 100644
+--- a/src/corelib/tools/qsimd_p.h
++++ b/src/corelib/tools/qsimd_p.h
+@@ -324,7 +324,7 @@
+ #endif
+ #endif
+ // AArch64/ARM64
+-#if defined(Q_PROCESSOR_ARM_V8) && defined(__ARM_FEATURE_CRC32)
++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
+ #define QT_FUNCTION_TARGET_STRING_CRC32      "+crc"
+ #  include <arm_acle.h>
+ #endif
+@@ -466,7 +466,7 @@ static const quint64 qCompilerCpuFeatures = 0
+ #if defined __ARM_NEON__
+         | (Q_UINT64_C(1) << CpuFeatureNEON)
+ #endif
+-#if defined __ARM_FEATURE_CRC32
++#if defined __aarch64__ && defined __ARM_FEATURE_CRC32
+         | (Q_UINT64_C(1) << CpuFeatureCRC32)
+ #endif
+ #if defined __mips_dsp
+-- 
+2.12.1
+
diff --git a/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch b/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
new file mode 120000
index 000000000..fce78e496
--- /dev/null
+++ b/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
@@ -0,0 +1 @@
+../5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
\ No newline@end of file
-- 
2.12.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 1/2] configs: raspberrypi3: fix mismatch cpu arch
  2017-04-16 15:14 ` [Buildroot] [RFC 1/2] " Gaël PORTAY
@ 2017-04-18 20:15   ` Arnout Vandecappelle
  2017-04-18 20:52     ` Gaël PORTAY
  2017-04-19 17:43   ` Ricardo Martincoski
  2017-05-02 20:40   ` Thomas Petazzoni
  2 siblings, 1 reply; 9+ messages in thread
From: Arnout Vandecappelle @ 2017-04-18 20:15 UTC (permalink / raw)
  To: buildroot



On 16-04-17 17:14, Ga?l PORTAY wrote:
> The raspberrypi3 is powered by a Broadcom BCM2837 which is a Cortex-A53.
> 
> Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>

Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

 Just to be sure: have you boot-tested the new defconfig?

 Regards,
 Arnout

> ---
>  configs/raspberrypi3_defconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig
> index 1b2134e0b..3d8949765 100644
> --- a/configs/raspberrypi3_defconfig
> +++ b/configs/raspberrypi3_defconfig
> @@ -1,5 +1,5 @@
>  BR2_arm=y
> -BR2_cortex_a7=y
> +BR2_cortex_a53=y
>  BR2_ARM_EABIHF=y
>  BR2_ARM_FPU_NEON_VFPV4=y
>  
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 1/2] configs: raspberrypi3: fix mismatch cpu arch
  2017-04-18 20:15   ` Arnout Vandecappelle
@ 2017-04-18 20:52     ` Gaël PORTAY
  0 siblings, 0 replies; 9+ messages in thread
From: Gaël PORTAY @ 2017-04-18 20:52 UTC (permalink / raw)
  To: buildroot

Arnout,

On Tue, Apr 18, 2017 at 10:15:30PM +0200, Arnout Vandecappelle wrote:
> 
> On 16-04-17 17:14, Ga?l PORTAY wrote:
> > The raspberrypi3 is powered by a Broadcom BCM2837 which is a Cortex-A53.
> > 
> > Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
> 
> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> 
>  Just to be sure: have you boot-tested the new defconfig?
> 

Yes, I have tested this new configuration.

As you can see in the second patch, this new configuration has broken the
compilation of qtbase.

>  Regards,
>  Arnout
> 

Regards,
Ga?l

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target
  2017-04-16 15:14 ` [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target Gaël PORTAY
@ 2017-04-18 21:32   ` Arnout Vandecappelle
  2017-07-15 23:22     ` Peter Seiderer
  0 siblings, 1 reply; 9+ messages in thread
From: Arnout Vandecappelle @ 2017-04-18 21:32 UTC (permalink / raw)
  To: buildroot



On 16-04-17 17:14, Ga?l PORTAY wrote:
> __ARM_FEATURE_CRC32 macro is set for armv8 cpus.
> 
> In case of a 32bits armv8 target, gcc complains about an unknown
> attribute +crc.
> 
> 	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
> 	 static uint crc32(const Char *ptr, size_t len, uint h)
> 
> This attribute looks to not be available in 32bits mode.

 That looks like a compiler bug, so I'm not sure this is the right fix.

 Also, I haven't been able to reproduce with a small test program (see below)
with various compilers I tried. Instead I get

/tmp/crc.c:7:1: warning: target attribute is not supported on this machine

I do get the link error in the end because of the missing __crc32w intrinsic. Or
when crc32 really is available (i.e. with -mcpu=cortex-a53), I get an assembler
error "selected processor does not support ARM mode `crc32w r3,r3,r2'". This
error I *don't* have when I use binutils 2.28, but I *do* have it with binutils
2.24. So my error sounds like a binutils issue.

 With which compiler did you have this issue?

crc.c:
------
#include <stdint.h>
#include <arm_acle.h>

__attribute__((__target__("+crc")))
int main(int argc, char *argv[])
{
  return __crc32w(0, *(uint32_t *)argv[0]);
}
------


 Note by the way that all cortex-aXX armv8-a processors seem to support the
optional CRC instruction, at least according to gcc. A processor that doesn't
have it is xgene1, but we don't support that one. So for Buildroot, the
target("+crc32") is pretty much redundant, since we always have -mcpu=cortex-aXX
for any processor that has __ARM_FEATURE_CRC32 set.

 Which makes me realize: the code in qhash.cpp is in fact rubbish... After
expanding a few macros, it basically has:

#if defined(__ARM_FEATURE_CRC32)
__attribute__((target("+crc32")))
static uint crc32(const Char *ptr, size_t len, uint h)

but __ARM_FEATURE_CRC32 is only defined if the compilation flags already contain
the equivalent of +crc32...


 So that makes me think that the proper (upstreamable) fix could be:

* Remove the bogus QT_FUNCTION_TARGET(CRC32) from qhash.cpp.

* Add a config.test that checks for broken assemblers that don't support the
crc32x instructions, and disable fast crc32 on those.


 Regards,
 Arnout



 Regards,
 Arnout


> If the
> attribute is bypassed (commented), the build breaks at linkage saying
> crc32x instructions are bad.
> 
> To solve this build issue, this patch checks for both __aarch64__ and
> __ARM_FEATURE_CRC32.
> 
> Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
> ---
>  ...ix-CRC-build-issue-on-32bits-armv8-target.patch | 95 ++++++++++++++++++++++
>  ...ix-CRC-build-issue-on-32bits-armv8-target.patch |  1 +
>  2 files changed, 96 insertions(+)
>  create mode 100644 package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
>  create mode 120000 package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> 
> diff --git a/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch b/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> new file mode 100644
> index 000000000..a648ea04d
> --- /dev/null
> +++ b/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> @@ -0,0 +1,95 @@
> +From 0382127e9f39f83e313ea279bc407d4eb6bd5e73 Mon Sep 17 00:00:00 2001
> +From: =?utf-8?q?Ga=C3=ABl=20PORTAY?= <gael.portay@savoirfairelinux.com>
> +Date: Tue, 11 Apr 2017 17:28:48 -0400
> +Subject: [PATCH] Fix CRC build issue on 32bits armv8 target
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=utf-8
> +Content-Transfer-Encoding: 8bit
> +
> +__ARM_FEATURE_CRC32 macro is set for armv8 cpus.
> +
> +In case of a 32bits armv8 target, gcc complains about an unknown
> +attribute +crc.
> +
> +	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
> +	 static uint crc32(const Char *ptr, size_t len, uint h)
> +
> +This attribute looks to not be available in 32bits mode. If the
> +attribute is bypassed (commented), the build breaks at linkage saying
> +crc32x instructions are bad.
> +
> +To solve this build issue, this patch checks for both __aarch64__ and
> +__ARM_FEATURE_CRC32.
> +
> +Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
> +---
> + config.tests/arch/arch.cpp  | 2 +-
> + src/corelib/tools/qhash.cpp | 2 +-
> + src/corelib/tools/qsimd.cpp | 2 +-
> + src/corelib/tools/qsimd_p.h | 4 ++--
> + 4 files changed, 5 insertions(+), 5 deletions(-)
> +
> +diff --git a/config.tests/arch/arch.cpp b/config.tests/arch/arch.cpp
> +index f99c5ca118..72f4af39fe 100644
> +--- a/config.tests/arch/arch.cpp
> ++++ b/config.tests/arch/arch.cpp
> +@@ -249,7 +249,7 @@ const char msg2[] = "==Qt=magic=Qt== Sub-architecture:"
> + #ifdef __IWMMXT__
> + " iwmmxt"
> + #endif
> +-#ifdef __ARM_FEATURE_CRC32
> ++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> + " crc32"
> + #endif
> + 
> +diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
> +index abec9ebb79..84cbe51731 100644
> +--- a/src/corelib/tools/qhash.cpp
> ++++ b/src/corelib/tools/qhash.cpp
> +@@ -137,7 +137,7 @@ static uint crc32(const Char *ptr, size_t len, uint h)
> +         h = _mm_crc32_u8(h, *p);
> +     return h;
> + }
> +-#elif defined(__ARM_FEATURE_CRC32)
> ++#elif defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> + static inline bool hasFastCrc32()
> + {
> +     return qCpuHasFeature(CRC32);
> +diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
> +index d4edf459de..f07cb2914a 100644
> +--- a/src/corelib/tools/qsimd.cpp
> ++++ b/src/corelib/tools/qsimd.cpp
> +@@ -136,7 +136,7 @@ static inline quint64 detectProcessorFeatures()
> + #if defined(__ARM_NEON__)
> +     features |= Q_UINT64_C(1) << CpuFeatureNEON;
> + #endif
> +-#if defined(__ARM_FEATURE_CRC32)
> ++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> +     features |= Q_UINT64_C(1) << CpuFeatureCRC32;
> + #endif
> + 
> +diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
> +index d5d887598e..92c93ea2e7 100644
> +--- a/src/corelib/tools/qsimd_p.h
> ++++ b/src/corelib/tools/qsimd_p.h
> +@@ -324,7 +324,7 @@
> + #endif
> + #endif
> + // AArch64/ARM64
> +-#if defined(Q_PROCESSOR_ARM_V8) && defined(__ARM_FEATURE_CRC32)
> ++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> + #define QT_FUNCTION_TARGET_STRING_CRC32      "+crc"
> + #  include <arm_acle.h>
> + #endif
> +@@ -466,7 +466,7 @@ static const quint64 qCompilerCpuFeatures = 0
> + #if defined __ARM_NEON__
> +         | (Q_UINT64_C(1) << CpuFeatureNEON)
> + #endif
> +-#if defined __ARM_FEATURE_CRC32
> ++#if defined __aarch64__ && defined __ARM_FEATURE_CRC32
> +         | (Q_UINT64_C(1) << CpuFeatureCRC32)
> + #endif
> + #if defined __mips_dsp
> +-- 
> +2.12.1
> +
> diff --git a/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch b/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> new file mode 120000
> index 000000000..fce78e496
> --- /dev/null
> +++ b/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> @@ -0,0 +1 @@
> +../5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> \ No newline at end of file
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 1/2] configs: raspberrypi3: fix mismatch cpu arch
  2017-04-16 15:14 ` [Buildroot] [RFC 1/2] " Gaël PORTAY
  2017-04-18 20:15   ` Arnout Vandecappelle
@ 2017-04-19 17:43   ` Ricardo Martincoski
  2017-05-02 20:40   ` Thomas Petazzoni
  2 siblings, 0 replies; 9+ messages in thread
From: Ricardo Martincoski @ 2017-04-19 17:43 UTC (permalink / raw)
  To: buildroot

Ga?l,

On Sun, Apr 16, 2017 at 12:14 PM, Ga?l PORTAY wrote:

> The raspberrypi3 is powered by a Broadcom BCM2837 which is a Cortex-A53.
> 
> Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>

Tested-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[boot-tested: I can login using the HDMI console]

Regards,
Ricardo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 1/2] configs: raspberrypi3: fix mismatch cpu arch
  2017-04-16 15:14 ` [Buildroot] [RFC 1/2] " Gaël PORTAY
  2017-04-18 20:15   ` Arnout Vandecappelle
  2017-04-19 17:43   ` Ricardo Martincoski
@ 2017-05-02 20:40   ` Thomas Petazzoni
  2 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2017-05-02 20:40 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 16 Apr 2017 11:14:08 -0400, Ga?l PORTAY wrote:
> The raspberrypi3 is powered by a Broadcom BCM2837 which is a Cortex-A53.
> 
> Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
> ---
>  configs/raspberrypi3_defconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, I have applied https://patchwork.ozlabs.org/patch/757022/
instead, which was a little bit more complete, but essentially does the
same thing.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target
  2017-04-18 21:32   ` Arnout Vandecappelle
@ 2017-07-15 23:22     ` Peter Seiderer
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Seiderer @ 2017-07-15 23:22 UTC (permalink / raw)
  To: buildroot

Hello Ga?l, Arnout,

On Tue, 18 Apr 2017 23:32:38 +0200, Arnout Vandecappelle <arnout@mind.be> wrote:

> 
> 
> On 16-04-17 17:14, Ga?l PORTAY wrote:
> > __ARM_FEATURE_CRC32 macro is set for armv8 cpus.
> > 
> > In case of a 32bits armv8 target, gcc complains about an unknown
> > attribute +crc.
> > 
> > 	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
> > 	 static uint crc32(const Char *ptr, size_t len, uint h)
> > 
> > This attribute looks to not be available in 32bits mode.
> 
>  That looks like a compiler bug, so I'm not sure this is the right fix.
> 
>  Also, I haven't been able to reproduce with a small test program (see below)
> with various compilers I tried. Instead I get
> 
> /tmp/crc.c:7:1: warning: target attribute is not supported on this machine
> 
> I do get the link error in the end because of the missing __crc32w intrinsic. Or
> when crc32 really is available (i.e. with -mcpu=cortex-a53), I get an assembler
> error "selected processor does not support ARM mode `crc32w r3,r3,r2'". This
> error I *don't* have when I use binutils 2.28, but I *do* have it with binutils
> 2.24. So my error sounds like a binutils issue.
> 
>  With which compiler did you have this issue?
> 
> crc.c:
> ------
> #include <stdint.h>
> #include <arm_acle.h>
> 
> __attribute__((__target__("+crc")))
> int main(int argc, char *argv[])
> {
>   return __crc32w(0, *(uint32_t *)argv[0]);
> }
> ------
> 
> 
>  Note by the way that all cortex-aXX armv8-a processors seem to support the
> optional CRC instruction, at least according to gcc. A processor that doesn't
> have it is xgene1, but we don't support that one. So for Buildroot, the
> target("+crc32") is pretty much redundant, since we always have -mcpu=cortex-aXX
> for any processor that has __ARM_FEATURE_CRC32 set.
> 
>  Which makes me realize: the code in qhash.cpp is in fact rubbish... After
> expanding a few macros, it basically has:
> 
> #if defined(__ARM_FEATURE_CRC32)
> __attribute__((target("+crc32")))
> static uint crc32(const Char *ptr, size_t len, uint h)
> 
> but __ARM_FEATURE_CRC32 is only defined if the compilation flags already contain
> the equivalent of +crc32...
> 
> 
>  So that makes me think that the proper (upstreamable) fix could be:
> 
> * Remove the bogus QT_FUNCTION_TARGET(CRC32) from qhash.cpp.
> 
> * Add a config.test that checks for broken assemblers that don't support the
> crc32x instructions, and disable fast crc32 on those.
> 

Suggested an alternative patch upstream [1],[2] and tested the qt5base compile
with binutils-2.28 and binutils-2.27+patch suggested in Bug 9916 [3] and posted
as two buildroot patches...

Regards,
Peter


[1] https://bugreports.qt.io/browse/QTBUG-61975
[2] https://codereview.qt-project.org/200171
[3] https://bugs.busybox.net/show_bug.cgi?id=9916
[4] http://lists.busybox.net/pipermail/buildroot/2017-July/198027.html
[5] http://lists.busybox.net/pipermail/buildroot/2017-July/198026.html

> 
>  Regards,
>  Arnout
> 
> 
> 
>  Regards,
>  Arnout
> 
> 
> > If the
> > attribute is bypassed (commented), the build breaks at linkage saying
> > crc32x instructions are bad.
> > 
> > To solve this build issue, this patch checks for both __aarch64__ and
> > __ARM_FEATURE_CRC32.
> > 
> > Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
> > ---
> >  ...ix-CRC-build-issue-on-32bits-armv8-target.patch | 95 ++++++++++++++++++++++
> >  ...ix-CRC-build-issue-on-32bits-armv8-target.patch |  1 +
> >  2 files changed, 96 insertions(+)
> >  create mode 100644 package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> >  create mode 120000 package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> > 
> > diff --git a/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch b/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> > new file mode 100644
> > index 000000000..a648ea04d
> > --- /dev/null
> > +++ b/package/qt5/qt5base/5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> > @@ -0,0 +1,95 @@
> > +From 0382127e9f39f83e313ea279bc407d4eb6bd5e73 Mon Sep 17 00:00:00 2001
> > +From: =?utf-8?q?Ga=C3=ABl=20PORTAY?= <gael.portay@savoirfairelinux.com>
> > +Date: Tue, 11 Apr 2017 17:28:48 -0400
> > +Subject: [PATCH] Fix CRC build issue on 32bits armv8 target
> > +MIME-Version: 1.0
> > +Content-Type: text/plain; charset=utf-8
> > +Content-Transfer-Encoding: 8bit
> > +
> > +__ARM_FEATURE_CRC32 macro is set for armv8 cpus.
> > +
> > +In case of a 32bits armv8 target, gcc complains about an unknown
> > +attribute +crc.
> > +
> > +	tools/qhash.cpp:148:54: error: attribute(target("+crc")) is unknown
> > +	 static uint crc32(const Char *ptr, size_t len, uint h)
> > +
> > +This attribute looks to not be available in 32bits mode. If the
> > +attribute is bypassed (commented), the build breaks at linkage saying
> > +crc32x instructions are bad.
> > +
> > +To solve this build issue, this patch checks for both __aarch64__ and
> > +__ARM_FEATURE_CRC32.
> > +
> > +Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
> > +---
> > + config.tests/arch/arch.cpp  | 2 +-
> > + src/corelib/tools/qhash.cpp | 2 +-
> > + src/corelib/tools/qsimd.cpp | 2 +-
> > + src/corelib/tools/qsimd_p.h | 4 ++--
> > + 4 files changed, 5 insertions(+), 5 deletions(-)
> > +
> > +diff --git a/config.tests/arch/arch.cpp b/config.tests/arch/arch.cpp
> > +index f99c5ca118..72f4af39fe 100644
> > +--- a/config.tests/arch/arch.cpp
> > ++++ b/config.tests/arch/arch.cpp
> > +@@ -249,7 +249,7 @@ const char msg2[] = "==Qt=magic=Qt== Sub-architecture:"
> > + #ifdef __IWMMXT__
> > + " iwmmxt"
> > + #endif
> > +-#ifdef __ARM_FEATURE_CRC32
> > ++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> > + " crc32"
> > + #endif
> > + 
> > +diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
> > +index abec9ebb79..84cbe51731 100644
> > +--- a/src/corelib/tools/qhash.cpp
> > ++++ b/src/corelib/tools/qhash.cpp
> > +@@ -137,7 +137,7 @@ static uint crc32(const Char *ptr, size_t len, uint h)
> > +         h = _mm_crc32_u8(h, *p);
> > +     return h;
> > + }
> > +-#elif defined(__ARM_FEATURE_CRC32)
> > ++#elif defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> > + static inline bool hasFastCrc32()
> > + {
> > +     return qCpuHasFeature(CRC32);
> > +diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
> > +index d4edf459de..f07cb2914a 100644
> > +--- a/src/corelib/tools/qsimd.cpp
> > ++++ b/src/corelib/tools/qsimd.cpp
> > +@@ -136,7 +136,7 @@ static inline quint64 detectProcessorFeatures()
> > + #if defined(__ARM_NEON__)
> > +     features |= Q_UINT64_C(1) << CpuFeatureNEON;
> > + #endif
> > +-#if defined(__ARM_FEATURE_CRC32)
> > ++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> > +     features |= Q_UINT64_C(1) << CpuFeatureCRC32;
> > + #endif
> > + 
> > +diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
> > +index d5d887598e..92c93ea2e7 100644
> > +--- a/src/corelib/tools/qsimd_p.h
> > ++++ b/src/corelib/tools/qsimd_p.h
> > +@@ -324,7 +324,7 @@
> > + #endif
> > + #endif
> > + // AArch64/ARM64
> > +-#if defined(Q_PROCESSOR_ARM_V8) && defined(__ARM_FEATURE_CRC32)
> > ++#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
> > + #define QT_FUNCTION_TARGET_STRING_CRC32      "+crc"
> > + #  include <arm_acle.h>
> > + #endif
> > +@@ -466,7 +466,7 @@ static const quint64 qCompilerCpuFeatures = 0
> > + #if defined __ARM_NEON__
> > +         | (Q_UINT64_C(1) << CpuFeatureNEON)
> > + #endif
> > +-#if defined __ARM_FEATURE_CRC32
> > ++#if defined __aarch64__ && defined __ARM_FEATURE_CRC32
> > +         | (Q_UINT64_C(1) << CpuFeatureCRC32)
> > + #endif
> > + #if defined __mips_dsp
> > +-- 
> > +2.12.1
> > +
> > diff --git a/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch b/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> > new file mode 120000
> > index 000000000..fce78e496
> > --- /dev/null
> > +++ b/package/qt5/qt5base/5.8.0/0005-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> > @@ -0,0 +1 @@
> > +../5.6.2/0003-Fix-CRC-build-issue-on-32bits-armv8-target.patch
> > \ No newline at end of file
> > 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-07-15 23:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-16 15:14 [Buildroot] [RFC 0/2] configs: raspberrypi3: fix mismatch cpu arch Gaël PORTAY
2017-04-16 15:14 ` [Buildroot] [RFC 1/2] " Gaël PORTAY
2017-04-18 20:15   ` Arnout Vandecappelle
2017-04-18 20:52     ` Gaël PORTAY
2017-04-19 17:43   ` Ricardo Martincoski
2017-05-02 20:40   ` Thomas Petazzoni
2017-04-16 15:14 ` [Buildroot] [RFC 2/2] qt5base: fix build issue on 32bits armv8 target Gaël PORTAY
2017-04-18 21:32   ` Arnout Vandecappelle
2017-07-15 23:22     ` Peter Seiderer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.