From a636fbea62aca8e44ea72a277d26b68a88a7a40b Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 14 Apr 2026 13:35:35 +0100 Subject: [PATCH] dev-libs/leancrypto: fix USE=asm w/ GCC 16; fix disabling doxygen for non-native ABI .. as mentioned in d79efc11894c98b7c9604bfaf3577499c9f66347. Signed-off-by: Sam James --- .../files/leancrypto-1.7.2-gcc-16-asm.patch | 45 +++++++++ .../leancrypto/leancrypto-1.7.2-r1.ebuild | 96 +++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 dev-libs/leancrypto/files/leancrypto-1.7.2-gcc-16-asm.patch create mode 100644 dev-libs/leancrypto/leancrypto-1.7.2-r1.ebuild diff --git a/dev-libs/leancrypto/files/leancrypto-1.7.2-gcc-16-asm.patch b/dev-libs/leancrypto/files/leancrypto-1.7.2-gcc-16-asm.patch new file mode 100644 index 0000000000000..b4b8aaa96f9b1 --- /dev/null +++ b/dev-libs/leancrypto/files/leancrypto-1.7.2-gcc-16-asm.patch @@ -0,0 +1,45 @@ +https://gcc.gnu.org/PR124877 +https://github.com/smuellerDD/leancrypto/issues/57 +https://github.com/smuellerDD/leancrypto/commit/489ce1a1d913e09a7f1107f61c4f969f866551ee + +From 489ce1a1d913e09a7f1107f61c4f969f866551ee Mon Sep 17 00:00:00 2001 +From: Stephan Mueller +Date: Tue, 14 Apr 2026 11:57:46 +0200 +Subject: [PATCH] Curve448 AVX2: fix ABI issue + +A uint8_t has to be copied into a register with movzbl as the upper +32 bits of a 64 bit movq instruction are undefined. + +Reported-bu: rguenth +Signed-off-by: Stephan Mueller +--- + curve448/src/avx2/gf_p4482241_nsqr.S | 2 +- + curve448/src/avx2/gf_p4482241_nsqrx.S | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/curve448/src/avx2/gf_p4482241_nsqr.S b/curve448/src/avx2/gf_p4482241_nsqr.S +index 3d54fa7a..d8907515 100644 +--- a/curve448/src/avx2/gf_p4482241_nsqr.S ++++ b/curve448/src/avx2/gf_p4482241_nsqr.S +@@ -93,7 +93,7 @@ movq %r13, 40(%rdi) + movq %r14, 48(%rdi) + movq %r15, 56(%rdi) + +-movq %rdx, %rcx ++movzbl %dl, %ecx + + .START: + +diff --git a/curve448/src/avx2/gf_p4482241_nsqrx.S b/curve448/src/avx2/gf_p4482241_nsqrx.S +index 0fee5d6a..04e62cd9 100644 +--- a/curve448/src/avx2/gf_p4482241_nsqrx.S ++++ b/curve448/src/avx2/gf_p4482241_nsqrx.S +@@ -91,7 +91,7 @@ movq %r12, 32(%rdi) + movq %r13, 40(%rdi) + movq %r14, 48(%rdi) + +-movq %rdx, %rbx ++movzbl %dl, %ebx + + .START_nsqrx: + diff --git a/dev-libs/leancrypto/leancrypto-1.7.2-r1.ebuild b/dev-libs/leancrypto/leancrypto-1.7.2-r1.ebuild new file mode 100644 index 0000000000000..8c1b2e9a1789a --- /dev/null +++ b/dev-libs/leancrypto/leancrypto-1.7.2-r1.ebuild @@ -0,0 +1,96 @@ +# Copyright 2025-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit dot-a meson-multilib toolchain-funcs + +DESCRIPTION="Lean cryptographic library usable for bare-metal environments " +HOMEPAGE="https://leancrypto.org/" + +if [[ ${PV} == 9999 ]] ; then + EGIT_REPO_URI="https://github.com/smuellerDD/leancrypto" + inherit git-r3 +else + VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/leancrypto.asc + inherit verify-sig + + SRC_URI=" + https://leancrypto.org/leancrypto/releases/${P}/${P}.tar.xz + verify-sig? ( https://leancrypto.org/leancrypto/releases/${P}/${P}.tar.xz.asc ) + " + + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~m68k ~riscv ~s390 ~sparc ~x86" + + BDEPEND=" + verify-sig? ( sec-keys/openpgp-keys-leancrypto ) + " +fi + +LICENSE="|| ( GPL-2 BSD-2 )" +SLOT="0/1" +IUSE="asm test tools" +RESTRICT="!test? ( test )" + +PATCHES=( + "${FILESDIR}"/${PN}-1.6.0-no-force-lto.patch + "${FILESDIR}"/${PN}-1.7.2-toolchain-hardening.patch + "${FILESDIR}"/${P}-gcc-16-asm.patch +) + +src_configure() { + use asm && MULTILIB_WRAPPED_HEADERS=( + # internal/api/meson.build modifies lc_memory_support + # based on asm support (bug #970513). Sort order here + # snakes out from that header. + /usr/include/leancrypto/lc_memory_support.h + /usr/include/leancrypto/ext_headers.h + + # Another root (LC_HASH_COMMON_ALIGNMENT) + /usr/include/leancrypto/lc_hash.h + /usr/include/leancrypto/lc_memset_secure.h + + # Another root (LC_DEF_ASCON_AVX512) + /usr/include/leancrypto/lc_ascon_hash.h + ) + + lto-guarantee-fat + meson-multilib_src_configure +} + +multilib_src_configure() { + tc-ld-is-mold && tc-ld-force-bfd + + local native_file="${T}"/meson.${CHOST}.${ABI}.ini.local + cat >> ${native_file} <<-EOF || die + [binaries] + doxygen='doxygen-falseified' + EOF + + local emesonargs=( + -Dstrip=false + $(meson_use !asm disable-asm) + $(meson_feature test tests) + $(meson_native_use_feature tools apps) + --native-file "${native_file}" + --cross-file "${native_file}" + ) + + if multilib_is_native_abi ; then + emesonargs+=( --native-file "${native_file}" ) + else + emesonargs+=( --cross-file "${native_file}" ) + fi + + meson_src_configure +} + +multilib_src_test() { + # Only run the regression tests rather than the performance ones + meson_src_test --timeout-multiplier=16 --suite=regression +} + +multilib_src_install_all() { + strip-lto-bytecode + einstalldocs +}