[packages/uv] And more x32 workarounds
arekm
arekm at pld-linux.org
Fri May 1 03:00:49 CEST 2026
commit 7c066ebab90a72f1c975d5fe0f69fba649cac488
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Fri May 1 03:00:25 2026 +0200
And more x32 workarounds
aws-lc-x32.patch | 59 ++++++++++++++++++++++++++++++++++++++------------------
uv.spec | 21 +++++++++++++-------
2 files changed, 54 insertions(+), 26 deletions(-)
---
diff --git a/uv.spec b/uv.spec
index 7997703..8eeede5 100644
--- a/uv.spec
+++ b/uv.spec
@@ -101,14 +101,21 @@ Zshowe dopełnianie składni dla polecenia uv.
%patch -P0 -p1
%endif
-# aws-lc-sys vendored source: skip RSAZ_mod_exp_avx512_x2 on x32
-# (BN_BITS2 != 64). Refresh the vendored crate checksum so cargo
-# accepts the modified file in offline mode.
-awslc_c=vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/bn/exponentiation.c
-old_sum=$(sha256sum "$awslc_c" | cut -f1 -d' ')
+# aws-lc-sys vendored source: gate RSAZ_ENABLED and EC_NISTP s2n-bignum
+# 64-bit paths on OPENSSL_64_BIT (broken on x32 where OPENSSL_X86_64 is
+# defined but BN_ULONG is uint32_t). Refresh vendored crate checksums
+# so cargo accepts the modified files in offline mode.
+awslc_files="vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/bn/rsaz_exp.h
+vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/ec/ec_nistp.h"
+for f in $awslc_files; do
+ sha256sum "$f"
+done > aws-lc-x32.sha256.old
%patch -P1 -p1
-new_sum=$(sha256sum "$awslc_c" | cut -f1 -d' ')
-%{__sed} -i -e "s/$old_sum/$new_sum/" vendor/aws-lc-sys/.cargo-checksum.json
+while read old_sum f; do
+ new_sum=$(sha256sum "$f" | cut -f1 -d' ')
+ %{__sed} -i -e "s/$old_sum/$new_sum/" vendor/aws-lc-sys/.cargo-checksum.json
+done < aws-lc-x32.sha256.old
+rm -f aws-lc-x32.sha256.old
# use our offline registry
export CARGO_HOME="$(pwd)/.cargo"
diff --git a/aws-lc-x32.patch b/aws-lc-x32.patch
index eb01d93..f9c9f8b 100644
--- a/aws-lc-x32.patch
+++ b/aws-lc-x32.patch
@@ -1,22 +1,43 @@
-aws-lc's RSAZ_mod_exp_avx512_x2 fast path is declared with uint64_t*
-parameters and is called from BN_mod_exp_mont_consttime_x2 with
-BN_ULONG*. On x86_64-gnu BN_ULONG == uint64_t so the call typechecks.
-On x32 (x86_64 ISA, 32-bit pointers) BN_ULONG == uint32_t but
-RSAZ_512_ENABLED is still set because the AVX-512 instructions exist —
-gcc then refuses with -Werror=incompatible-pointer-types.
+aws-lc has two gates that condition optimized 64-bit-limb code paths
+on OPENSSL_X86_64 alone. On x32 (x86_64 ISA, 32-bit pointers, 32-bit
+BN_ULONG) OPENSSL_X86_64 is correctly defined but OPENSSL_64_BIT is
+not, and the optimized paths break with -Wincompatible-pointer-types
+because they expect uint64_t* arguments while callers pass uint32_t*.
-Gate the fast path on BN_BITS2 == 64 so x32 (and any future ABI with
-32-bit BN_ULONG on x86_64-class hardware) falls back to the generic
-constant-time modular exponentiation path.
+Add `defined(OPENSSL_64_BIT)` to both gates so x32 falls through to
+the portable Fiat-crypto / generic constant-time paths whose word
+size matches BN_ULONG. Same correctness invariant in two places: the
+optimized 64-bit-limb routines require an actual 64-bit BN_ULONG, not
+just an x86_64 instruction set.
---- a/vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/bn/exponentiation.c
-+++ b/vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/bn/exponentiation.c
-@@ -1176,7 +1176,7 @@
- {
- int ret = 0;
+This fixes the cascade of errors in:
+ crypto/fipsmodule/bn/exponentiation.c (RSAZ_mod_exp_avx512_x2)
+ crypto/fipsmodule/ec/p256.c (ec_nistp_scalar_mul_public)
+ crypto/fipsmodule/ec/p256-nistz.c (ecp_nistz256_*, bignum_montinv_p256)
+ crypto/fipsmodule/ec/p384.c, p521.c (*_jscalarmul_selector)
--#ifdef RSAZ_512_ENABLED
-+#if defined(RSAZ_512_ENABLED) && BN_BITS2 == 64
- if (CRYPTO_is_AVX512IFMA_capable() &&
- (((a1->width == 16) && (p1->width == 16) && (BN_num_bits(m1) == 1024) &&
- (a2->width == 16) && (p2->width == 16) && (BN_num_bits(m2) == 1024)) ||
+at their root in the two header gates that flip the limb typedef and
+enable the AVX-512 RSAZ path.
+
+--- a/vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/bn/rsaz_exp.h
++++ b/vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/bn/rsaz_exp.h
+@@ -20,7 +20,8 @@
+ extern "C" {
+ #endif
+
+-#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
++#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
++ defined(OPENSSL_64_BIT) && \
+ !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX)
+ #define RSAZ_ENABLED
+
+--- a/vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/ec/ec_nistp.h
++++ b/vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/ec/ec_nistp.h
+@@ -17,6 +17,7 @@
+ // set, s2n-bignum path is capable.
+ #if !defined(OPENSSL_NO_ASM) && \
+ (defined(OPENSSL_LINUX) || defined(OPENSSL_APPLE)) && \
++ defined(OPENSSL_64_BIT) && \
+ ((defined(OPENSSL_X86_64) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX)) || \
+ defined(OPENSSL_AARCH64))
+ # define EC_NISTP_USE_S2N_BIGNUM
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/uv.git/commitdiff/7c066ebab90a72f1c975d5fe0f69fba649cac488
More information about the pld-cvs-commit
mailing list