diff options
4 files changed, 158 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-ckzg/blst-0001-Support-64-bit-limbs-on-no-asm-platforms.patch b/meta-python/recipes-devtools/python/python3-ckzg/blst-0001-Support-64-bit-limbs-on-no-asm-platforms.patch new file mode 100644 index 0000000000..e112db9dea --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-ckzg/blst-0001-Support-64-bit-limbs-on-no-asm-platforms.patch | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | From: Ulrich Weigand <ulrich.weigand@de.ibm.com> | ||
| 2 | Date: Fri, 4 Mar 2022 17:41:12 +0100 | ||
| 3 | Subject: [PATCH] Support 64-bit limbs on no-asm platforms | ||
| 4 | |||
| 5 | Currently, platforms without assembler support always use 32-bit limbs, | ||
| 6 | but the Rust bindings always assume 64-bit limbs. This breaks on | ||
| 7 | big-endian platforms like our IBM Z (s390x). | ||
| 8 | |||
| 9 | This patch enables 64-bit limbs on 64-bit platforms even if there is | ||
| 10 | no hand-written assembler, by using a 128-bit integer type in the | ||
| 11 | C implementation (this is an extension that is widely supported on | ||
| 12 | 64-bit platforms with GCC or LLVM). | ||
| 13 | |||
| 14 | Note that this means that the argument "n" to quot_rem_n is no | ||
| 15 | longer guaranteed to always be a multiple of 2, so the corresponding | ||
| 16 | assertion needs to be removed as well. | ||
| 17 | |||
| 18 | This fixes the broken Rust bindings on IBM Z, and also improves | ||
| 19 | performance by a factor or 3 or more, because compiler-generated | ||
| 20 | code handling __int128 already uses the 64x64->128 multiply | ||
| 21 | instruction our ISA provides. | ||
| 22 | |||
| 23 | To improve performance of compiler-generated code a bit more, this | ||
| 24 | also switches to the -O3 optimization level, which helps with | ||
| 25 | unrolling of the Montgomery multiply core loop. | ||
| 26 | |||
| 27 | Upstream-Status: Pending | ||
| 28 | |||
| 29 | diff --git a/blst/bindings/rust/build.rs b/blst/bindings/rust/build.rs | ||
| 30 | index d823057..093a072 100644 | ||
| 31 | --- a/blst/bindings/rust/build.rs | ||
| 32 | +++ b/blst/bindings/rust/build.rs | ||
| 33 | @@ -234,7 +234,11 @@ fn main() { | ||
| 34 | cc.define("SCRATCH_LIMIT", "(45 * 1024)"); | ||
| 35 | } | ||
| 36 | if !cfg!(debug_assertions) { | ||
| 37 | - cc.opt_level(2); | ||
| 38 | + if target_arch.eq("s390x") { | ||
| 39 | + cc.opt_level(3); | ||
| 40 | + } else { | ||
| 41 | + cc.opt_level(2); | ||
| 42 | + } | ||
| 43 | } | ||
| 44 | cc.files(&file_vec).compile("blst"); | ||
| 45 | |||
| 46 | diff --git a/blst/src/no_asm.h b/blst/src/no_asm.h | ||
| 47 | index be7bf47..802b78f 100644 | ||
| 48 | --- a/blst/src/no_asm.h | ||
| 49 | +++ b/blst/src/no_asm.h | ||
| 50 | @@ -6,6 +6,8 @@ | ||
| 51 | |||
| 52 | #if LIMB_T_BITS==32 | ||
| 53 | typedef unsigned long long llimb_t; | ||
| 54 | +#else | ||
| 55 | +typedef unsigned __int128 llimb_t; | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #if !defined(__STDC_VERSION__) || __STDC_VERSION__<199901 || defined(__STDC_NO_VLA__) | ||
| 59 | @@ -1155,7 +1157,7 @@ limb_t div_3_limbs(const limb_t div_top[2], limb_t d_lo, limb_t d_hi) | ||
| 60 | static limb_t quot_rem_n(limb_t *div_rem, const limb_t *divisor, | ||
| 61 | limb_t quotient, size_t n) | ||
| 62 | { | ||
| 63 | - __builtin_assume(n != 0 && n%2 == 0); | ||
| 64 | + __builtin_assume(n != 0); | ||
| 65 | llimb_t limbx; | ||
| 66 | limb_t tmp[n+1], carry, mask, borrow; | ||
| 67 | size_t i; | ||
| 68 | diff --git a/blst/src/vect.h b/blst/src/vect.h | ||
| 69 | index 19640b1..938a5ff 100644 | ||
| 70 | --- a/blst/src/vect.h | ||
| 71 | +++ b/blst/src/vect.h | ||
| 72 | @@ -18,7 +18,7 @@ typedef unsigned long long limb_t; | ||
| 73 | typedef unsigned __int64 limb_t; | ||
| 74 | # define LIMB_T_BITS 64 | ||
| 75 | |||
| 76 | -#elif defined(__BLST_NO_ASM__) || defined(__wasm64__) | ||
| 77 | +#elif defined(__wasm64__) | ||
| 78 | typedef unsigned int limb_t; | ||
| 79 | # define LIMB_T_BITS 32 | ||
| 80 | # ifndef __BLST_NO_ASM__ | ||
| 81 | @@ -31,8 +31,10 @@ typedef unsigned long limb_t; | ||
| 82 | # define LIMB_T_BITS 64 | ||
| 83 | # else | ||
| 84 | # define LIMB_T_BITS 32 | ||
| 85 | -# define __BLST_NO_ASM__ | ||
| 86 | # endif | ||
| 87 | +# ifndef __BLST_NO_ASM__ | ||
| 88 | +# define __BLST_NO_ASM__ | ||
| 89 | +# endif | ||
| 90 | #endif | ||
| 91 | |||
| 92 | /* | ||
diff --git a/meta-python/recipes-devtools/python/python3-ckzg/python-ckzg-0001-Let-override-CC.patch b/meta-python/recipes-devtools/python/python3-ckzg/python-ckzg-0001-Let-override-CC.patch new file mode 100644 index 0000000000..c58089cc15 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-ckzg/python-ckzg-0001-Let-override-CC.patch | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | From: Peter Lemenkov <lemenkov@gmail.com> | ||
| 2 | Date: Wed, 6 Nov 2024 16:35:23 +0300 | ||
| 3 | Subject: [PATCH] Let override CC | ||
| 4 | |||
| 5 | Upstream-Status: Pending | ||
| 6 | |||
| 7 | Signed-off-by: Peter Lemenkov <lemenkov@gmail.com> | ||
| 8 | |||
| 9 | diff --git a/src/Makefile b/src/Makefile | ||
| 10 | index b733a11..c688005 100644 | ||
| 11 | --- a/src/Makefile | ||
| 12 | +++ b/src/Makefile | ||
| 13 | @@ -79,7 +79,7 @@ ifeq ($(PLATFORM),Windows) | ||
| 14 | CFLAGS += -D_CRT_SECURE_NO_WARNINGS | ||
| 15 | CFLAGS += -Wno-missing-braces -Wno-format | ||
| 16 | else | ||
| 17 | - CC = clang | ||
| 18 | + CC ?= clang | ||
| 19 | CFLAGS += -fPIC | ||
| 20 | CFLAGS += -Wmissing-braces -Wformat=2 | ||
| 21 | endif | ||
diff --git a/meta-python/recipes-devtools/python/python3-ckzg/python-ckzg-0002-Disable-Werror.patch b/meta-python/recipes-devtools/python/python3-ckzg/python-ckzg-0002-Disable-Werror.patch new file mode 100644 index 0000000000..9b0baa358a --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-ckzg/python-ckzg-0002-Disable-Werror.patch | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | From: rpm-build <rpm-build> | ||
| 2 | Date: Tue, 26 Nov 2024 11:13:18 +0100 | ||
| 3 | Subject: [PATCH] Disable Werror | ||
| 4 | |||
| 5 | Upstream-Status: Pending | ||
| 6 | |||
| 7 | Signed-off-by: rpm-build <rpm-build> | ||
| 8 | |||
| 9 | diff --git a/src/Makefile b/src/Makefile | ||
| 10 | index c688005..01b7a80 100644 | ||
| 11 | --- a/src/Makefile | ||
| 12 | +++ b/src/Makefile | ||
| 13 | @@ -20,7 +20,7 @@ ifeq ($(PLATFORM),Darwin) | ||
| 14 | endif | ||
| 15 | |||
| 16 | # The base compiler flags. More can be added on command line. | ||
| 17 | -CFLAGS += -I. -I../inc -O2 -Werror | ||
| 18 | +CFLAGS += -I. -I../inc | ||
| 19 | # Enable a bunch of optional warnings. | ||
| 20 | CFLAGS += \ | ||
| 21 | -pedantic \ | ||
| 22 | @@ -81,7 +81,7 @@ ifeq ($(PLATFORM),Windows) | ||
| 23 | else | ||
| 24 | CC ?= clang | ||
| 25 | CFLAGS += -fPIC | ||
| 26 | - CFLAGS += -Wmissing-braces -Wformat=2 | ||
| 27 | + CFLAGS += -Wmissing-braces | ||
| 28 | endif | ||
| 29 | |||
| 30 | # Settings for blst. | ||
diff --git a/meta-python/recipes-devtools/python/python3-ckzg_2.1.1.bb b/meta-python/recipes-devtools/python/python3-ckzg_2.1.1.bb new file mode 100644 index 0000000000..5a6196bf75 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-ckzg_2.1.1.bb | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | SUMMARY = "Python Bindings for the C-KZG Library" | ||
| 2 | HOMEPAGE = "https://github.com/ethereum/c-kzg-4844" | ||
| 3 | SECTION = "devel/python" | ||
| 4 | LICENSE = "Apache-2.0" | ||
| 5 | LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327" | ||
| 6 | |||
| 7 | SRC_URI += " \ | ||
| 8 | file://blst-0001-Support-64-bit-limbs-on-no-asm-platforms.patch \ | ||
| 9 | file://python-ckzg-0001-Let-override-CC.patch \ | ||
| 10 | file://python-ckzg-0002-Disable-Werror.patch \ | ||
| 11 | " | ||
| 12 | |||
| 13 | SRC_URI[sha256sum] = "d6b306b7ec93a24e4346aa53d07f7f75053bc0afc7398e35fa649e5f9d48fcc4" | ||
| 14 | |||
| 15 | inherit pypi setuptools3 | ||
