From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] package/botan: fix build on mips
Date: Thu, 11 Nov 2021 22:16:20 +0100 [thread overview]
Message-ID: <20211111211620.GF2609@scaer> (raw)
In-Reply-To: <20211109220106.1645006-1-fontaine.fabrice@gmail.com>
Fabrice, All,
On 2021-11-09 23:01 +0100, Fabrice Fontaine spake thusly:
> Fix the following build failure on one mips toolchain with gcc 5.3
> raised since bump to version 2.18.2 in commit
> 47fa16dffa6c6a72b2f76984f6d492f4f352a52b:
>
> src/lib/hash/sha3/sha3.cpp: In function 'std::tuple<long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int> Botan::{anonymous}::xor_CNs(const uint64_t*)':
> src/lib/hash/sha3/sha3.cpp:41:42: error: converting to 'std::tuple<long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int>' from initializer list would use explicit constructor 'constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int}; <template-parameter-2-2> = void; _Elements = {long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int}]'
> A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24]};
> ^
>
> Fixes:
> - http://autobuild.buildroot.org/results/4e86c3008aa70284a3002f426066fcc21d018e95
>
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
I've added a small note that the revert is innocuous for us, and is
suggested by upstream, and then applied to master, thanks.
Regards,
Yann E. MORIN.
> ---
> ...d-a-miscompilation-issue-in-clang-12.patch | 144 ++++++++++++++++++
> 1 file changed, 144 insertions(+)
> create mode 100644 package/botan/0001-Revert-workaround-a-miscompilation-issue-in-clang-12.patch
>
> diff --git a/package/botan/0001-Revert-workaround-a-miscompilation-issue-in-clang-12.patch b/package/botan/0001-Revert-workaround-a-miscompilation-issue-in-clang-12.patch
> new file mode 100644
> index 0000000000..b43aeafe13
> --- /dev/null
> +++ b/package/botan/0001-Revert-workaround-a-miscompilation-issue-in-clang-12.patch
> @@ -0,0 +1,144 @@
> +From 372bdf0348fb86d671e73baab19daa34bd0cf73d Mon Sep 17 00:00:00 2001
> +From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +Date: Tue, 9 Nov 2021 19:01:20 +0100
> +Subject: [PATCH] Revert "workaround a miscompilation issue in clang 12
> + (XCode 13)"
> +
> +This reverts commit 219329f8e777af54d785ae7259f8be32a714b751.
> +
> +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +[Upstream status: https://github.com/randombit/botan/issues/2845]
> +---
> + src/lib/hash/sha3/sha3.cpp | 46 ++++++-----------------
> + src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp | 46 ++++++-----------------
> + 2 files changed, 22 insertions(+), 70 deletions(-)
> +
> +diff --git a/src/lib/hash/sha3/sha3.cpp b/src/lib/hash/sha3/sha3.cpp
> +index 289e451ff..690c2b264 100644
> +--- a/src/lib/hash/sha3/sha3.cpp
> ++++ b/src/lib/hash/sha3/sha3.cpp
> +@@ -11,47 +11,23 @@
> + #include <botan/exceptn.h>
> + #include <botan/cpuid.h>
> +
> +-#include <tuple>
> +-
> + namespace Botan {
> +
> + namespace {
> +
> +-// This is a workaround for a suspected bug in clang 12 (and XCode 13)
> +-// that caused a miscompile of the SHA3 implementation for optimization
> +-// level -O2 and higher.
> +-//
> +-// For details, see: https://github.com/randombit/botan/issues/2802
> +-#if defined(__clang__) && \
> +- (( defined(__apple_build_version__) && __clang_major__ == 13) || \
> +- (!defined(__apple_build_version__) && __clang_major__ == 12))
> +-#define BOTAN_WORKAROUND_MAYBE_INLINE __attribute__((noinline))
> +-#else
> +-#define BOTAN_WORKAROUND_MAYBE_INLINE inline
> +-#endif
> +-
> +-BOTAN_WORKAROUND_MAYBE_INLINE std::tuple<uint64_t, uint64_t, uint64_t, uint64_t, uint64_t>
> +- xor_CNs(const uint64_t A[25])
> +- {
> +- return {
> +- A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20],
> +- A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21],
> +- A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22],
> +- A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23],
> +- A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24]};
> +- }
> +-
> +-#undef BOTAN_WORKAROUND_MAYBE_INLINE
> +-
> + inline void SHA3_round(uint64_t T[25], const uint64_t A[25], uint64_t RC)
> + {
> +- const auto Cs = xor_CNs(A);
> +-
> +- const uint64_t D0 = rotl<1>(std::get<0>(Cs)) ^ std::get<3>(Cs);
> +- const uint64_t D1 = rotl<1>(std::get<1>(Cs)) ^ std::get<4>(Cs);
> +- const uint64_t D2 = rotl<1>(std::get<2>(Cs)) ^ std::get<0>(Cs);
> +- const uint64_t D3 = rotl<1>(std::get<3>(Cs)) ^ std::get<1>(Cs);
> +- const uint64_t D4 = rotl<1>(std::get<4>(Cs)) ^ std::get<2>(Cs);
> ++ const uint64_t C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20];
> ++ const uint64_t C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21];
> ++ const uint64_t C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22];
> ++ const uint64_t C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23];
> ++ const uint64_t C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24];
> ++
> ++ const uint64_t D0 = rotl<1>(C0) ^ C3;
> ++ const uint64_t D1 = rotl<1>(C1) ^ C4;
> ++ const uint64_t D2 = rotl<1>(C2) ^ C0;
> ++ const uint64_t D3 = rotl<1>(C3) ^ C1;
> ++ const uint64_t D4 = rotl<1>(C4) ^ C2;
> +
> + const uint64_t B00 = A[ 0] ^ D1;
> + const uint64_t B01 = rotl<44>(A[ 6] ^ D2);
> +diff --git a/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp b/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp
> +index c7f1914a3..a9650ad9d 100644
> +--- a/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp
> ++++ b/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp
> +@@ -8,47 +8,23 @@
> + #include <botan/sha3.h>
> + #include <botan/rotate.h>
> +
> +-#include <tuple>
> +-
> + namespace Botan {
> +
> + namespace {
> +
> +-// This is a workaround for a suspected bug in clang 12 (and XCode 13)
> +-// that caused a miscompile of the SHA3 implementation for optimization
> +-// level -O2 and higher.
> +-//
> +-// For details, see: https://github.com/randombit/botan/issues/2802
> +-#if defined(__clang__) && \
> +- (( defined(__apple_build_version__) && __clang_major__ == 13) || \
> +- (!defined(__apple_build_version__) && __clang_major__ == 12))
> +-#define BOTAN_WORKAROUND_MAYBE_INLINE __attribute__((noinline))
> +-#else
> +-#define BOTAN_WORKAROUND_MAYBE_INLINE inline
> +-#endif
> +-
> +-BOTAN_WORKAROUND_MAYBE_INLINE std::tuple<uint64_t, uint64_t, uint64_t, uint64_t, uint64_t>
> +- xor_CNs(const uint64_t A[25])
> +- {
> +- return {
> +- A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20],
> +- A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21],
> +- A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22],
> +- A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23],
> +- A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24]};
> +- }
> +-
> +-#undef BOTAN_WORKAROUND_MAYBE_INLINE
> +-
> + inline void SHA3_BMI2_round(uint64_t T[25], const uint64_t A[25], uint64_t RC)
> + {
> +- const auto Cs = xor_CNs(A);
> +-
> +- const uint64_t D0 = rotl<1>(std::get<0>(Cs)) ^ std::get<3>(Cs);
> +- const uint64_t D1 = rotl<1>(std::get<1>(Cs)) ^ std::get<4>(Cs);
> +- const uint64_t D2 = rotl<1>(std::get<2>(Cs)) ^ std::get<0>(Cs);
> +- const uint64_t D3 = rotl<1>(std::get<3>(Cs)) ^ std::get<1>(Cs);
> +- const uint64_t D4 = rotl<1>(std::get<4>(Cs)) ^ std::get<2>(Cs);
> ++ const uint64_t C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20];
> ++ const uint64_t C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21];
> ++ const uint64_t C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22];
> ++ const uint64_t C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23];
> ++ const uint64_t C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24];
> ++
> ++ const uint64_t D0 = rotl<1>(C0) ^ C3;
> ++ const uint64_t D1 = rotl<1>(C1) ^ C4;
> ++ const uint64_t D2 = rotl<1>(C2) ^ C0;
> ++ const uint64_t D3 = rotl<1>(C3) ^ C1;
> ++ const uint64_t D4 = rotl<1>(C4) ^ C2;
> +
> + const uint64_t B00 = A[ 0] ^ D1;
> + const uint64_t B01 = rotl<44>(A[ 6] ^ D2);
> +--
> +2.33.0
> +
> --
> 2.33.0
>
> _______________________________________________
> 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
prev parent reply other threads:[~2021-11-11 21:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 22:01 [Buildroot] [PATCH 1/1] package/botan: fix build on mips Fabrice Fontaine
2021-11-11 21:16 ` Yann E. MORIN [this message]
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=20211111211620.GF2609@scaer \
--to=yann.morin.1998@free.fr \
--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 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.