Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Cc: Bernd Kuhls <bernd.kuhls@t-online.de>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] package/libdeflate: fix aarch64 build
Date: Mon, 26 Dec 2022 22:10:13 +0100	[thread overview]
Message-ID: <20221226211013.GF2893@scaer> (raw)
In-Reply-To: <20221226102305.406593-1-fontaine.fabrice@gmail.com>

Fabrice, All,

On 2022-12-26 11:23 +0100, Fabrice Fontaine spake thusly:
> Fix the following aarch64 build failure raised since the addition of the
> package in commit 4231e7b10b87de71e33bb9906eede3751bed5dfe:
> 
> In file included from /home/autobuild/autobuild/instance-22/output-1/build/libdeflate-1.15/lib/arm/crc32_impl.h:256,
>                  from /home/autobuild/autobuild/instance-22/output-1/build/libdeflate-1.15/lib/crc32.c:227:
> /home/autobuild/autobuild/instance-22/output-1/build/libdeflate-1.15/lib/arm/crc32_impl.h: In function 'clmul_u32':
> /home/autobuild/autobuild/instance-22/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/10.4.0/include/arm_neon.h:26723:1: error: inlining failed in call to 'always_inline' 'vmull_p64': target specific option mismatch
> 26723 | vmull_p64 (poly64_t __a, poly64_t __b)
>       | ^~~~~~~~~
> In file included from /home/autobuild/autobuild/instance-22/output-1/build/libdeflate-1.15/lib/crc32.c:227:
> /home/autobuild/autobuild/instance-22/output-1/build/libdeflate-1.15/lib/arm/crc32_impl.h:262:19: note: called from here
>   262 |  uint64x2_t res = vreinterpretq_u64_p128(
>       |                   ^~~~~~~~~~~~~~~~~~~~~~~
>   263 |     compat_vmull_p64((poly64_t)a, (poly64_t)b));
>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/9aee8dafea614db77209818b913a571534466506
>  - http://autobuild.buildroot.org/results/951d5a1a2959a0cc65ca7e52967ec07bc1cc00f1
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  ...-target-when-required-due-to-gcc-bug.patch | 90 +++++++++++++++++++
>  1 file changed, 90 insertions(+)
>  create mode 100644 package/libdeflate/0001-lib-arm-crc32-use-crypto-target-when-required-due-to-gcc-bug.patch
> 
> diff --git a/package/libdeflate/0001-lib-arm-crc32-use-crypto-target-when-required-due-to-gcc-bug.patch b/package/libdeflate/0001-lib-arm-crc32-use-crypto-target-when-required-due-to-gcc-bug.patch
> new file mode 100644
> index 0000000000..8823ec4b39
> --- /dev/null
> +++ b/package/libdeflate/0001-lib-arm-crc32-use-crypto-target-when-required-due-to-gcc-bug.patch
> @@ -0,0 +1,90 @@
> +From f8f022e5bc574088ae80327ea5f88a8fe09b48c8 Mon Sep 17 00:00:00 2001
> +From: Eric Biggers <ebiggers3@gmail.com>
> +Date: Sun, 25 Dec 2022 15:05:52 -0800
> +Subject: [PATCH] lib/arm/crc32: use crypto target when required due to gcc bug
> +
> +Fixes https://github.com/ebiggers/libdeflate/issues/280
> +Fixes: 6db64ab7afd2 ("lib/crc32: CRC-32 optimizations and other improvements")
> +[Retrieved from:
> +https://github.com/ebiggers/libdeflate/commit/f8f022e5bc574088ae80327ea5f88a8fe09b48c8]
> +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +---
> + lib/arm/cpu_features.h | 23 +++++++++++++++++++++++
> + lib/arm/crc32_impl.h   |  9 +++++----
> + 2 files changed, 28 insertions(+), 4 deletions(-)
> +
> +diff --git a/lib/arm/cpu_features.h b/lib/arm/cpu_features.h
> +index 204c0cd5..4092eba8 100644
> +--- a/lib/arm/cpu_features.h
> ++++ b/lib/arm/cpu_features.h
> +@@ -116,6 +116,29 @@ static inline u32 get_arm_cpu_features(void) { return 0; }
> + #else
> + #  define HAVE_PMULL_INTRIN	0
> + #endif
> ++/*
> ++ * Set USE_PMULL_TARGET_EVEN_IF_NATIVE if a workaround for a gcc bug that was
> ++ * fixed by commit 11a113d501ff ("aarch64: Simplify feature definitions") in gcc
> ++ * 13 is needed.  A minimal program that fails to build due to this bug when
> ++ * compiled with -mcpu=emag, at least with gcc 10 through 12, is:
> ++ *
> ++ *    static inline __attribute__((always_inline,target("+crypto"))) void f() {}
> ++ *    void g() { f(); }
> ++ *
> ++ * The error is:
> ++ *
> ++ *    error: inlining failed in call to ‘always_inline’ ‘f’: target specific option mismatch
> ++ *
> ++ * The workaround is to explicitly add the crypto target to the non-inline
> ++ * function g(), even though this should not be required due to -mcpu=emag
> ++ * enabling 'crypto' natively and causing __ARM_FEATURE_CRYPTO to be defined.
> ++ */
> ++#if HAVE_PMULL_NATIVE && defined(ARCH_ARM64) && \
> ++		GCC_PREREQ(6, 1) && !GCC_PREREQ(13, 1)
> ++#  define USE_PMULL_TARGET_EVEN_IF_NATIVE	1
> ++#else
> ++#  define USE_PMULL_TARGET_EVEN_IF_NATIVE	0
> ++#endif
> + 
> + /* CRC32 */
> + #ifdef __ARM_FEATURE_CRC32
> +diff --git a/lib/arm/crc32_impl.h b/lib/arm/crc32_impl.h
> +index e426a63d..b9300e4b 100644
> +--- a/lib/arm/crc32_impl.h
> ++++ b/lib/arm/crc32_impl.h
> +@@ -236,7 +236,7 @@ crc32_arm_crc(u32 crc, const u8 *p, size_t len)
> +  * for implementations that use pmull for folding the data itself.
> +  */
> + #if HAVE_CRC32_INTRIN && HAVE_PMULL_INTRIN
> +-#  if HAVE_CRC32_NATIVE && HAVE_PMULL_NATIVE
> ++#  if HAVE_CRC32_NATIVE && HAVE_PMULL_NATIVE && !USE_PMULL_TARGET_EVEN_IF_NATIVE
> + #    define ATTRIBUTES
> + #  else
> + #    ifdef ARCH_ARM32
> +@@ -438,7 +438,7 @@ crc32_arm_crc_pmullcombine(u32 crc, const u8 *p, size_t len)
> + #if HAVE_PMULL_INTRIN
> + #  define crc32_arm_pmullx4	crc32_arm_pmullx4
> + #  define SUFFIX			 _pmullx4
> +-#  if HAVE_PMULL_NATIVE
> ++#  if HAVE_PMULL_NATIVE && !USE_PMULL_TARGET_EVEN_IF_NATIVE
> + #    define ATTRIBUTES
> + #  else
> + #    ifdef ARCH_ARM32
> +@@ -558,7 +558,7 @@ crc32_arm_pmullx4(u32 crc, const u8 *p, size_t len)
> + #if defined(ARCH_ARM64) && HAVE_PMULL_INTRIN && HAVE_CRC32_INTRIN
> + #  define crc32_arm_pmullx12_crc	crc32_arm_pmullx12_crc
> + #  define SUFFIX				 _pmullx12_crc
> +-#  if HAVE_PMULL_NATIVE && HAVE_CRC32_NATIVE
> ++#  if HAVE_PMULL_NATIVE && HAVE_CRC32_NATIVE && !USE_PMULL_TARGET_EVEN_IF_NATIVE
> + #    define ATTRIBUTES
> + #  else
> + #    ifdef __clang__
> +@@ -584,7 +584,8 @@ crc32_arm_pmullx4(u32 crc, const u8 *p, size_t len)
> + 	(HAVE_SHA3_TARGET || HAVE_SHA3_NATIVE)
> + #  define crc32_arm_pmullx12_crc_eor3	crc32_arm_pmullx12_crc_eor3
> + #  define SUFFIX				 _pmullx12_crc_eor3
> +-#  if HAVE_PMULL_NATIVE && HAVE_CRC32_NATIVE && HAVE_SHA3_NATIVE
> ++#  if HAVE_PMULL_NATIVE && HAVE_CRC32_NATIVE && HAVE_SHA3_NATIVE && \
> ++	!USE_PMULL_TARGET_EVEN_IF_NATIVE
> + #    define ATTRIBUTES
> + #  else
> + #    ifdef __clang__
> -- 
> 2.35.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2022-12-26 21:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26 10:23 [Buildroot] [PATCH 1/1] package/libdeflate: fix aarch64 build Fabrice Fontaine
2022-12-26 21:10 ` Yann E. MORIN [this message]
2023-01-01 18:13 ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221226211013.GF2893@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=bernd.kuhls@t-online.de \
    --cc=buildroot@buildroot.org \
    --cc=fontaine.fabrice@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox