From 3fd1cb6aecde35b08c927a8accbe1065e97c1168 Mon Sep 17 00:00:00 2001 From: shaojian-ant <121606618+shaojian-ant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:01:58 +0800 Subject: [PATCH] repo-sync-2024-12-19T15:23:27+0800 (#454) --- .gitignore | 3 + MODULE.bazel | 15 +- bazel/FourQlib.BUILD | 70 -------- bazel/hash_drbg.BUILD | 29 ---- bazel/lib25519.BUILD | 294 -------------------------------- bazel/libsodium.BUILD | 74 -------- bazel/mcl.BUILD | 105 ------------ bazel/patches/FourQlib.patch | 126 -------------- bazel/patches/brpc.patch | 170 ------------------ bazel/patches/brpc_crypto.patch | 30 ---- bazel/patches/brpc_m1.patch | 12 -- bazel/patches/leveldb.patch | 22 --- bazel/patches/libtommath.patch | 26 --- bazel/patches/mcl.patch | 123 ------------- bazel/patches/msgpack.patch | 16 -- bazel/patches/protobuf.patch | 16 -- bazel/sse2neon.BUILD | 20 --- bazel/tongsuo.BUILD | 67 -------- yacl/crypto/hash/blake3_test.cc | 27 ++- 19 files changed, 24 insertions(+), 1221 deletions(-) delete mode 100644 bazel/FourQlib.BUILD delete mode 100644 bazel/hash_drbg.BUILD delete mode 100644 bazel/lib25519.BUILD delete mode 100644 bazel/libsodium.BUILD delete mode 100644 bazel/mcl.BUILD delete mode 100644 bazel/patches/FourQlib.patch delete mode 100644 bazel/patches/brpc.patch delete mode 100644 bazel/patches/brpc_crypto.patch delete mode 100644 bazel/patches/brpc_m1.patch delete mode 100644 bazel/patches/leveldb.patch delete mode 100644 bazel/patches/libtommath.patch delete mode 100644 bazel/patches/mcl.patch delete mode 100644 bazel/patches/msgpack.patch delete mode 100644 bazel/patches/protobuf.patch delete mode 100644 bazel/sse2neon.BUILD delete mode 100644 bazel/tongsuo.BUILD diff --git a/.gitignore b/.gitignore index 8cf35551..d0e447bd 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,6 @@ external #brpc rpc_data + +.clwb +cmake-build-debug-remote diff --git a/MODULE.bazel b/MODULE.bazel index 997f21f5..cc44e1e5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -25,16 +25,12 @@ module( ) # --registry=https://bcr.bazel.build +bazel_dep(name = "protobuf", version = "27.3") bazel_dep(name = "rules_proto", version = "4.0.0") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "apple_support", version = "1.17.1") -bazel_dep(name = "rules_cc", version = "0.0.12") -single_version_override( - module_name = "rules_cc", - version = "0.0.12", -) - -bazel_dep(name = "abseil-cpp", version = "20230802.1") +bazel_dep(name = "rules_cc", version = "0.0.13") +bazel_dep(name = "abseil-cpp", version = "20240722.0") bazel_dep(name = "gflags", version = "2.2.2") bazel_dep(name = "zlib", version = "1.3.1.bcr.3") bazel_dep(name = "msgpack-c", version = "6.1.0") @@ -59,11 +55,6 @@ bazel_dep(name = "hash_drbg", version = "0.0.0-20230516-2411fa9") bazel_dep(name = "org_interconnection", version = "0.0.1") bazel_dep(name = "lib25519", version = "20240321") bazel_dep(name = "mcl", version = "1.99") -bazel_dep(name = "protobuf", version = "25.5") -single_version_override( - module_name = "protobuf", - version = "25.5", -) # --registry=https://baidu.github.io/babylon/registry bazel_dep(name = "leveldb", version = "1.23") diff --git a/bazel/FourQlib.BUILD b/bazel/FourQlib.BUILD deleted file mode 100644 index a8738b34..00000000 --- a/bazel/FourQlib.BUILD +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright 2024 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@rules_foreign_cc//foreign_cc:defs.bzl", "make") - -filegroup( - name = "all_srcs", - srcs = glob(["**"]), -) - -config_setting( - name = "linux_x64", - constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", - ], -) - -config_setting( - name = "linux_arm64", - constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:aarch64", - ], -) - -make( - name = "FourQlib", - args = ["-C FourQ_64bit_and_portable"], - defines = [ - "__LINUX__", - "_ARM64_", - ], # still work on macos and x64 - env = select({ - ":linux_x64": { - "ARCH": "x64", - "AVX": "TRUE", - "AVX2": "FALSE", - "EXTENDED_SET": "FALSE", - }, - ":linux_arm64": { - "ARCH": "ARM64", - "GENERIC": "TRUE", - "EXTENDED_SET": "FALSE", - }, - "@platforms//os:macos": { - "ARCH": "x64", - "GENERIC": "TRUE", - "EXTENDED_SET": "FALSE", - }, # still work on macos M1 - }), - lib_source = ":all_srcs", - out_static_libs = ["libFourQ.a"], - targets = [ - "libFourQ", - "install", - ], - visibility = ["//visibility:public"], -) diff --git a/bazel/hash_drbg.BUILD b/bazel/hash_drbg.BUILD deleted file mode 100644 index 025628cb..00000000 --- a/bazel/hash_drbg.BUILD +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2023 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "hash_drbg", - srcs = [ - "hash_drbg.c", - "hash_drbg_error_codes.h", - ], - hdrs = ["hash_drbg.h"], - copts = ["-Wno-parentheses"], - visibility = ["//visibility:public"], - deps = [ - "@yacl//yacl/crypto:openssl_wrappers", - ], -) diff --git a/bazel/lib25519.BUILD b/bazel/lib25519.BUILD deleted file mode 100644 index 2d3adabd..00000000 --- a/bazel/lib25519.BUILD +++ /dev/null @@ -1,294 +0,0 @@ -# Copyright 2024 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@rules_cc//cc:defs.bzl", "cc_library") - -genrule( - name = "crypto_uint64_h", - srcs = ["inttypes/crypto_uintN.h"], - outs = ["include-build/crypto_uint64.h"], - cmd = "sed -e 's/N/64/g' $(<) > $(@)", -) - -genrule( - name = "crypto_verify_c", - srcs = ["crypto_verify/32/ref/verify.c"], - outs = ["crypto_verify.c"], - cmd = "cat $(<) > $(@)", -) - -genrule( - name = "crypto_verify_h", - outs = ["include-build/crypto_verify.h"], - cmd = """ -cat > $@ << EOF -#ifndef crypto_verify_h -#define crypto_verify_h - -#define crypto_verify CRYPTO_NAMESPACE(verify) - -#define crypto_verify_32_BYTES 32 -#define crypto_verify_BYTES 32 - -extern int crypto_verify(const unsigned char *,const unsigned char *); - -#endif - -EOF""", -) - -genrule( - name = "ge25519_unpack_c", - srcs = ["crypto_multiscalar/ed25519/amd64-maax-p3/ge25519_unpack.c"], - outs = ["ge25519_unpack.c"], - cmd = "sed -e 's/crypto_verify_32/crypto_verify/g' $(<) > $(@)", -) - -genrule( - name = "ge25519_sub_h", - outs = ["include-build/ge25519_sub.h"], - cmd = """ -cat > $@ << EOF -#ifndef ge25519_sub_h -#define ge25519_sub_h - -#include "ge25519.h" - -#define ge25519_sub CRYPTO_NAMESPACE(ge25519_sub) - -extern void ge25519_sub(ge25519 *r, const ge25519 *p, const ge25519 *q); - -#endif - -EOF""", -) - -genrule( - name = "ge25519_sub_c", - outs = ["ge25519_sub.c"], - cmd = """ -cat > $@ << EOF -#include "ge25519_sub.h" - -void ge25519_sub(ge25519 *r, const ge25519 *p, const ge25519 *q) -{ - ge25519_p3 qneg; - fe25519_neg(&qneg.x,&q->x); - fe25519_neg(&qneg.t,&q->t); - qneg.y = q->y; - qneg.z = q->z; - ge25519_add(r,p,&qneg); -} - -EOF""", -) - -genrule( - name = "ge25519_scalarmult_h", - outs = ["include-build/ge25519_scalarmult.h"], - cmd = """ -cat > $@ << EOF -#ifndef ge25519_scalarmult_h -#define ge25519_scalarmult_h - -#include "ge25519.h" - -#define ge25519_scalarmult CRYPTO_NAMESPACE(ge25519_scalarmult) - -extern void ge25519_scalarmult(ge25519 *r, const ge25519 *p, const sc25519 *s); - -#endif - -EOF""", -) - -genrule( - name = "ge25519_scalarmult_c", - outs = ["ge25519_scalarmult.c"], - cmd = """ -cat > $@ << EOF -#include "ge25519_scalarmult.h" -#include "ge25519_sub.h" - -// warning: these constants are not encapsulated -#define P_WINDOWSIZE 5 -#define P_MULTIPLES (1<<(P_WINDOWSIZE-2)) -static void ge25519_p3_0(ge25519_p3 *r) -{ - fe25519_setint(&r->x,0); - fe25519_setint(&r->y,1); - fe25519_setint(&r->z,1); - fe25519_setint(&r->t,0); -} -static void ge25519_multi_scalarmult_precompute(ge25519_p3 *cP, const ge25519_p3 *P, unsigned long long multiples) -{ - __attribute__ ((aligned(32))) ge25519_p3 twoP; - ge25519_double(&twoP,P); - cP[0] = *P; - for (long long i = 0;i < multiples-1;++i) - ge25519_add(&cP[i+1],&twoP,&cP[i]); -} -static void ge25519_multi_scalarmult_process(ge25519_p3 *r, const signed char nslide[256], const ge25519_p3 cP[P_MULTIPLES]) -{ - int maybenonzero = 0; - ge25519_p3_0(r); - for (long long i = 255;i >= 0;--i) { - if (maybenonzero) - ge25519_double(r,r); - signed char c = nslide[i]; - if (c != 0) { - maybenonzero = 1; - if (c > 0) - ge25519_add(r,r,&cP[c/2]); - else - ge25519_sub(r,r,&cP[-c/2]); - } - } -} -void ge25519_scalarmult(ge25519 *r, const ge25519 *p, const sc25519 *s) { - signed char nslide[256]; - ge25519_p3 cP[P_MULTIPLES]; /* P,3P,5P,7P,9P,11P,13P,15P */ - sc25519_slide(nslide,s,P_WINDOWSIZE); - ge25519_multi_scalarmult_precompute(cP,p,P_MULTIPLES); - ge25519_multi_scalarmult_process(r,nslide,cP); -} - -EOF""", -) - -genrule( - name = "ge25519_is_on_curve_h", - outs = ["include-build/ge25519_is_on_curve.h"], - cmd = """ -cat > $@ << EOF -#ifndef ge25519_is_on_curve_h -#define ge25519_is_on_curve_h - -#include "ge25519.h" - -#define ge25519_is_on_curve CRYPTO_NAMESPACE(ge25519_is_on_curve) - -extern int ge25519_is_on_curve(const ge25519 *p); - -#endif - -EOF""", -) - -genrule( - name = "ge25519_is_on_curve_c", - outs = ["ge25519_is_on_curve.c"], - cmd = """ -cat > $@ << EOF -#include "ge25519_is_on_curve.h" - -/* d */ -static const fe25519 ecd = {{0x75EB4DCA135978A3, 0x00700A4D4141D8AB, 0x8CC740797779E898, 0x52036CEE2B6FFE73}}; - -static const fe25519 zero = {{0,0,0,0}}; - -int ge25519_is_on_curve(const ge25519_p3 *p) -{ - fe25519 x2; - fe25519 y2; - fe25519 z2; - fe25519 z4; - fe25519 t0; - fe25519 t1; - - fe25519_square(&x2, &p->x); - fe25519_square(&y2, &p->y); - fe25519_square(&z2, &p->z); - fe25519_sub(&t0, &y2, &x2); - fe25519_mul(&t0, &t0, &z2); - - fe25519_mul(&t1, &x2, &y2); - fe25519_mul(&t1, &t1, &ecd); - fe25519_square(&z4, &z2); - fe25519_add(&t1, &t1, &z4); - fe25519_sub(&t0, &t0, &t1); - - return fe25519_iseq_vartime(&t0, &zero) != 0; -} - -EOF""", -) - -cc_library( - name = "25519", - srcs = [ - "crypto_mGnP/ed25519/amd64-maax/ge25519_pack.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_add.S", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_freeze.S", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_getparity.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_iseq.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_mul.S", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_neg.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_pack.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_pow2523.c", # referenced by ge25519_unpack - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_setint.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_sub.S", - "crypto_multiscalar/ed25519/amd64-maax-p3/fe25519_unpack.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/ge25519_add.S", - "crypto_multiscalar/ed25519/amd64-maax-p3/ge25519_double.S", - "crypto_multiscalar/ed25519/amd64-maax-p3/sc25519_from32bytes.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/sc25519_slide.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/sc25519_to32bytes.c", - "crypto_multiscalar/ed25519/amd64-maax-p3/shared-consts.c", - "crypto_nG/merged25519/amd64-maax/fe25519_cmov.c", - "crypto_nG/merged25519/amd64-maax/ge25519_base.S", - "crypto_nG/merged25519/amd64-maax/ge25519_scalarmult_base.c", - "crypto_nG/merged25519/amd64-maax/sc25519_window4.c", - "crypto_nG/merged25519/amd64-maax/shared-base-data.c", - "crypto_pow/inv25519/amd64-maax/fe25519_invert.c", - "crypto_pow/inv25519/amd64-maax/fe25519_nsquare.S", - "crypto_pow/inv25519/amd64-maax/fe25519_square.S", - "crypto_verify.c", - "ge25519_is_on_curve.c", - "ge25519_scalarmult.c", - "ge25519_sub.c", - "ge25519_unpack.c", - "include-build/crypto_asm_hidden.h", - "include-build/crypto_uint64.h", - "include-build/crypto_verify.h", - ], - hdrs = [ - "crypto_multiscalar/ed25519/amd64-maax-p3/ge25519_unpack.h", - "crypto_multiscalar/ed25519/amd64-maax-p3/sc25519.h", - "crypto_nG/merged25519/amd64-maax/fe25519.h", - "crypto_nG/merged25519/amd64-maax/ge25519.h", - "crypto_nG/merged25519/amd64-maax/ge25519_base_niels.data", - "include-build/ge25519_is_on_curve.h", - "include-build/ge25519_scalarmult.h", - "include-build/ge25519_sub.h", - ], - copts = ["-fvisibility=hidden"], - defines = [ - "CRYPTO_NAMESPACE(name)=crypto_##name", - "_CRYPTO_NAMESPACE(name)=_crypto_##name", - "CRYPTO_SHARED_NAMESPACE(name)=crypto_shared_##name", - "_CRYPTO_SHARED_NAMESPACE(name)=_crypto_shared_##name", - ], - includes = [ - "crypto_multiscalar/ed25519/amd64-maax-p3", - "crypto_nG/merged25519/amd64-maax", - "include-build", - ], - linkstatic = True, - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - visibility = ["//visibility:public"], -) diff --git a/bazel/libsodium.BUILD b/bazel/libsodium.BUILD deleted file mode 100644 index d304826d..00000000 --- a/bazel/libsodium.BUILD +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2022 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@rules_cc//cc:defs.bzl", "cc_library") - -genrule( - name = "gen_sh", - outs = ["gen.sh"], - cmd = """ -cat > $@ <<"EOF" -#!/bin/sh -sed -e 's/@VERSION@/1.0.18/g' \ - -e 's/@SODIUM_LIBRARY_VERSION_MAJOR@/11/g' \ - -e 's/@SODIUM_LIBRARY_VERSION_MINOR@/0/g' \ - -e 's/@SODIUM_LIBRARY_MINIMAL_DEF@//g' -EOF""", -) - -genrule( - name = "version_h", - srcs = ["src/libsodium/include/sodium/version.h.in"], - outs = ["src/libsodium/include/sodium/version.h"], - cmd = "$(location :gen_sh) < $(<) > $(@)", - tools = [":gen_sh"], -) - -cc_library( - name = "libsodium", - srcs = glob( - include = ["src/**/*.c"], - ) + [":version_h"], - hdrs = glob(["src/**/*.h"] + [":version_h"]), - copts = [ - "-DCONFIGURED", - "-DHAVE_TI_MODE", - ], - includes = [ - "src/libsodium/crypto_core/curve25519/ref10", - "src/libsodium/crypto_generichash/blake2b/ref", - "src/libsodium/crypto_onetimeauth/poly1305", - "src/libsodium/crypto_onetimeauth/poly1305/donna", - "src/libsodium/crypto_onetimeauth/poly1305/sse2", - "src/libsodium/crypto_pwhash/argon2", - "src/libsodium/crypto_pwhash/scryptsalsa208sha256", - "src/libsodium/crypto_scalarmult/curve25519", - "src/libsodium/crypto_scalarmult/curve25519/donna_c64", - "src/libsodium/crypto_scalarmult/curve25519/ref10", - "src/libsodium/crypto_scalarmult/curve25519/sandy2x", - "src/libsodium/crypto_shorthash/siphash24/ref", - "src/libsodium/crypto_sign/ed25519/ref10", - "src/libsodium/crypto_stream/chacha20", - "src/libsodium/crypto_stream/chacha20/dolbeau", - "src/libsodium/crypto_stream/chacha20/ref", - "src/libsodium/crypto_stream/salsa20", - "src/libsodium/crypto_stream/salsa20/ref", - "src/libsodium/crypto_stream/salsa20/xmm6", - "src/libsodium/crypto_stream/salsa20/xmm6int", - "src/libsodium/include", - "src/libsodium/include/sodium", - "src/libsodium/include/sodium/private", - ], - visibility = ["//visibility:public"], -) diff --git a/bazel/mcl.BUILD b/bazel/mcl.BUILD deleted file mode 100644 index b89377b9..00000000 --- a/bazel/mcl.BUILD +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright 2024 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@bazel_skylib//lib:selects.bzl", "selects") -load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake", "make") - -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "source", - srcs = glob(["**"]), -) - -# This is the value could be defined by --config=android_arm64 -config_setting( - name = "cpu_arm64_v8a", - values = {"cpu": "arm64-v8a"}, - visibility = ["//visibility:private"], -) - -selects.config_setting_group( - name = "mac_x86", - match_all = [ - "@platforms//os:macos", - "@platforms//cpu:x86_64", - ], -) - -default_config = { - "MCL_BUILD_TESTING": "OFF", - # remove dependency on libgmp - "MCL_TEST_WITH_GMP": "OFF", - "MCL_STATIC_LIB": "ON", -} - -android_config = { - "MCL_BUILD_TESTING": "OFF", - # remove dependency on libgmp - "MCL_TEST_WITH_GMP": "OFF", - "MCL_STATIC_LIB": "ON", - "MCL_USE_LLVM": "OFF", - "CMAKE_SYSTEM_NAME": "Android", - "CMAKE_ANDROID_NDK": "$ANDROID_NDK_HOME", - "CMAKE_ANDROID_ARCH_ABI": "arm64-v8a", -} - -# bad for mac intel -# https://github.com/herumi/mcl/issues/174 -cmake( - name = "mcl-cmake", - build_args = ["-j"], - cache_entries = select({ - ":cpu_arm64_v8a": android_config, - "//conditions:default": default_config, - }), - generate_args = ["-G Ninja"], - # generate_crosstool_file = False, - lib_source = ":source", - out_static_libs = [ - "libmcl.a", - ], - alwayslink = True, -) - -make( - name = "mcl-make", - args = [ - "-j", - "MCL_USE_GMP=0", - "DEBUG=0", - ], - env = select({ - "@platforms//os:macos": { - "AR": "ar", - }, - "//conditions:default": { - }, - }), - lib_source = ":source", - out_static_libs = [ - "libmcl.a", - ], - targets = [ - "install", - ], -) - -cc_library( - name = "mcl", - deps = select({ - ":mac_x86": [":mcl-make"], - "//conditions:default": [":mcl-cmake"], - }), -) diff --git a/bazel/patches/FourQlib.patch b/bazel/patches/FourQlib.patch deleted file mode 100644 index 75e85d9c..00000000 --- a/bazel/patches/FourQlib.patch +++ /dev/null @@ -1,126 +0,0 @@ -diff --git a/FourQ_64bit_and_portable/FourQ_internal.h b/FourQ_64bit_and_portable/FourQ_internal.h -index 30d4387..5104320 100644 ---- a/FourQ_64bit_and_portable/FourQ_internal.h -+++ b/FourQ_64bit_and_portable/FourQ_internal.h -@@ -128,15 +128,15 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y) - - // 64x64-bit multiplication - #define MUL128(multiplier, multiplicand, product) \ -- mp_mul((digit_t*)&(multiplier), (digit_t*)&(multiplicand), (digit_t*)&(product), NWORDS_FIELD/2); -+ FourQlib_mp_mul((digit_t*)&(multiplier), (digit_t*)&(multiplicand), (digit_t*)&(product), NWORDS_FIELD/2); - - // 128-bit addition, inputs < 2^127 - #define ADD128(addend1, addend2, addition) \ -- mp_add((digit_t*)(addend1), (digit_t*)(addend2), (digit_t*)(addition), NWORDS_FIELD); -+ FourQlib_mp_add((digit_t*)(addend1), (digit_t*)(addend2), (digit_t*)(addition), NWORDS_FIELD); - - // 128-bit addition with output carry - #define ADC128(addend1, addend2, carry, addition) \ -- (carry) = mp_add((digit_t*)(addend1), (digit_t*)(addend2), (digit_t*)(addition), NWORDS_FIELD); -+ (carry) = FourQlib_mp_add((digit_t*)(addend1), (digit_t*)(addend2), (digit_t*)(addition), NWORDS_FIELD); - - #elif (TARGET == TARGET_AMD64 && OS_TARGET == OS_WIN) - -@@ -228,10 +228,10 @@ static __inline unsigned int is_digit_lessthan_ct(digit_t x, digit_t y) - bool is_zero_ct(digit_t* a, unsigned int nwords); - - // Multiprecision addition, c = a+b. Returns the carry bit --unsigned int mp_add(digit_t* a, digit_t* b, digit_t* c, unsigned int nwords); -+unsigned int FourQlib_mp_add(digit_t* a, digit_t* b, digit_t* c, unsigned int nwords); - - // Schoolbook multiprecision multiply, c = a*b --void mp_mul(const digit_t* a, const digit_t* b, digit_t* c, const unsigned int nwords); -+void FourQlib_mp_mul(const digit_t* a, const digit_t* b, digit_t* c, const unsigned int nwords); - - // Multiprecision subtraction, c = a-b. Returns the borrow bit - #if defined (GENERIC_IMPLEMENTATION) -diff --git a/FourQ_64bit_and_portable/generic/fp.h b/FourQ_64bit_and_portable/generic/fp.h -index 3083c06..e51997d 100644 ---- a/FourQ_64bit_and_portable/generic/fp.h -+++ b/FourQ_64bit_and_portable/generic/fp.h -@@ -183,7 +183,7 @@ void mod1271(felm_t a) - } - - --void mp_mul(const digit_t* a, const digit_t* b, digit_t* c, const unsigned int nwords) -+void FourQlib_mp_mul(const digit_t* a, const digit_t* b, digit_t* c, const unsigned int nwords) - { // Schoolbook multiprecision multiply, c = a*b - unsigned int i, j; - digit_t u, v, UV[2]; -@@ -206,7 +206,7 @@ void mp_mul(const digit_t* a, const digit_t* b, digit_t* c, const unsigned int n - } - - --unsigned int mp_add(digit_t* a, digit_t* b, digit_t* c, unsigned int nwords) -+unsigned int FourQlib_mp_add(digit_t* a, digit_t* b, digit_t* c, unsigned int nwords) - { // Multiprecision addition, c = a+b, where lng(a) = lng(b) = nwords. Returns the carry bit - unsigned int i, carry = 0; - -@@ -270,14 +270,14 @@ void fpinv1271(felm_t a) - static __inline void multiply(const digit_t* a, const digit_t* b, digit_t* c) - { // Schoolbook multiprecision multiply, c = a*b - -- mp_mul(a, b, c, NWORDS_ORDER); -+ FourQlib_mp_mul(a, b, c, NWORDS_ORDER); - } - - - static __inline unsigned int add(const digit_t* a, const digit_t* b, digit_t* c, const unsigned int nwords) - { // Multiprecision addition, c = a+b, where lng(a) = lng(b) = nwords. Returns the carry bit - -- return mp_add((digit_t*)a, (digit_t*)b, c, (unsigned int)nwords); -+ return FourQlib_mp_add((digit_t*)a, (digit_t*)b, c, (unsigned int)nwords); - } - - -diff --git a/FourQ_64bit_and_portable/makefile b/FourQ_64bit_and_portable/makefile -index 7b6fd07..3bf1f56 100644 ---- a/FourQ_64bit_and_portable/makefile -+++ b/FourQ_64bit_and_portable/makefile -@@ -92,9 +92,13 @@ ifeq "$(SERIAL_PUSH)" "TRUE" - endif - - SHARED_LIB_TARGET=libFourQ.so -+STATIC_LIB_TARGET=libFourQ.a - ifeq "$(SHARED_LIB)" "TRUE" - DO_MAKE_SHARED_LIB=-fPIC - SHARED_LIB_O=$(SHARED_LIB_TARGET) -+else -+ DO_MAKE_SHARED_LIB=-fPIC -+ STATIC_LIB_O=$(STATIC_LIB_TARGET) - endif - - cc=$(COMPILER) -@@ -116,8 +120,11 @@ OBJECTS_ALL=$(OBJECTS) $(OBJECTS_FP_TEST) $(OBJECTS_ECC_TEST) $(OBJECTS_CRYPTO_T - all: crypto_test ecc_test fp_test $(SHARED_LIB_O) - - ifeq "$(SHARED_LIB)" "TRUE" -- $(SHARED_LIB_O): $(OBJECTS) -+ libFourQ: $(OBJECTS) - $(CC) -shared -o $(SHARED_LIB_O) $(OBJECTS) -+else -+ libFourQ: $(OBJECTS) -+ ar rcs $(STATIC_LIB_O) $(OBJECTS) - endif - - crypto_test: $(OBJECTS_CRYPTO_TEST) -@@ -186,3 +193,6 @@ fp_tests.o: tests/fp_tests.c - clean: - rm -rf $(SHARED_LIB_TARGET) crypto_test ecc_test fp_test *.o AMD64/consts.s - -+install: -+ cp $(STATIC_LIB_O) $(SHARED_LIB_O) $(PREFIX)/lib -+ cp FourQ.h FourQ_api.h FourQ_internal.h ../random/random.h $(PREFIX)/include -diff --git a/FourQ_64bit_and_portable/schnorrq.c b/FourQ_64bit_and_portable/schnorrq.c -index da89f86..040db60 100644 ---- a/FourQ_64bit_and_portable/schnorrq.c -+++ b/FourQ_64bit_and_portable/schnorrq.c -@@ -14,7 +14,7 @@ - #include "FourQ_params.h" - #include "../random/random.h" - #include "../sha512/sha512.h" --#include -+#include - #include - - diff --git a/bazel/patches/brpc.patch b/bazel/patches/brpc.patch deleted file mode 100644 index b1dbb245..00000000 --- a/bazel/patches/brpc.patch +++ /dev/null @@ -1,170 +0,0 @@ -diff --git a/src/brpc/policy/http_rpc_protocol.cpp b/src/brpc/policy/http_rpc_protocol.cpp -index 7bd06ec5..68b1a58d 100644 ---- a/src/brpc/policy/http_rpc_protocol.cpp -+++ b/src/brpc/policy/http_rpc_protocol.cpp -@@ -617,12 +617,12 @@ void SerializeHttpRequest(butil::IOBuf* /*not used*/, - - Span* span = accessor.span(); - if (span) { -- hreq.SetHeader("x-bd-trace-id", butil::string_printf( -- "%llu", (unsigned long long)span->trace_id())); -- hreq.SetHeader("x-bd-span-id", butil::string_printf( -- "%llu", (unsigned long long)span->span_id())); -- hreq.SetHeader("x-bd-parent-span-id", butil::string_printf( -- "%llu", (unsigned long long)span->parent_span_id())); -+ hreq.SetHeader("x-b3-traceid", butil::string_printf( -+ "%016llx", (unsigned long long)span->trace_id())); -+ hreq.SetHeader("x-b3-spanid", butil::string_printf( -+ "%016llx", (unsigned long long)span->span_id())); -+ hreq.SetHeader("x-b3-parentspanid", butil::string_printf( -+ "%016llx", (unsigned long long)span->parent_span_id())); - } - } - -@@ -1282,22 +1282,22 @@ void ProcessHttpRequest(InputMessageBase *msg) { - - Span* span = NULL; - const std::string& path = req_header.uri().path(); -- const std::string* trace_id_str = req_header.GetHeader("x-bd-trace-id"); -+ const std::string* trace_id_str = req_header.GetHeader("x-b3-traceid"); - if (IsTraceable(trace_id_str)) { - uint64_t trace_id = 0; - if (trace_id_str) { -- trace_id = strtoull(trace_id_str->c_str(), NULL, 10); -+ trace_id = strtoull(trace_id_str->c_str(), NULL, 16); - } - uint64_t span_id = 0; -- const std::string* span_id_str = req_header.GetHeader("x-bd-span-id"); -+ const std::string* span_id_str = req_header.GetHeader("x-b3-spanid"); - if (span_id_str) { -- span_id = strtoull(span_id_str->c_str(), NULL, 10); -+ span_id = strtoull(span_id_str->c_str(), NULL, 16); - } - uint64_t parent_span_id = 0; - const std::string* parent_span_id_str = -- req_header.GetHeader("x-bd-parent-span-id"); -+ req_header.GetHeader("x-b3-parentspanid"); - if (parent_span_id_str) { -- parent_span_id = strtoull(parent_span_id_str->c_str(), NULL, 10); -+ parent_span_id = strtoull(parent_span_id_str->c_str(), NULL, 16); - } - span = Span::CreateServerSpan( - path, trace_id, span_id, parent_span_id, msg->base_real_us()); -diff --git a/src/bvar/default_variables.cpp b/src/bvar/default_variables.cpp -index be02c50a..186abe54 100644 ---- a/src/bvar/default_variables.cpp -+++ b/src/bvar/default_variables.cpp -@@ -110,8 +110,9 @@ static bool read_proc_status(ProcStat &stat) { - return -1; - } - const std::string& result = oss.str(); -+ // macOS flags is actually a hex, ref https://github.com/apache/incubator-brpc/issues/1106 - if (sscanf(result.c_str(), "%d %d %d %d" -- "%d %u %ld %ld", -+ "%d %x %ld %ld", - &stat.pid, &stat.ppid, &stat.pgrp, &stat.session, - &stat.tpgid, &stat.flags, &stat.priority, &stat.nice) != 8) { - PLOG(WARNING) << "Fail to sscanf"; -@@ -635,7 +636,7 @@ public: - bool operator()(rusage* stat) const { - const int rc = getrusage(RUSAGE_SELF, stat); - if (rc < 0) { -- PLOG(WARNING) << "Fail to getrusage"; -+ // PLOG(WARNING) << "Fail to getrusage"; - return false; - } - return true; -diff --git a/BUILD.bazel b/BUILD.bazel -index 0bdaa4d3..b23881b3 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -51,7 +51,7 @@ LINKOPTS = [ - "-pthread", - "-ldl", - ] + select({ -- "@bazel_tools//tools/osx:darwin": [ -+ "@bazel_tools//src/conditions:darwin": [ - "-framework CoreFoundation", - "-framework CoreGraphics", - "-framework CoreData", -@@ -217,7 +217,7 @@ BUTIL_SRCS = [ - "src/butil/recordio.cc", - "src/butil/popen.cpp", - ] + select({ -- "@bazel_tools//tools/osx:darwin": [ -+ "@bazel_tools//src/conditions:darwin": [ - "src/butil/time/time_mac.cc", - "src/butil/mac/scoped_mach_port.cc", - ], -@@ -326,13 +326,13 @@ cc_library( - visibility = ["//visibility:public"], - deps = [ - "@gflags//:gflags", -- "@com_github_madler_zlib//:zlib", -+ "@zlib//:zlib", - "@com_google_protobuf//:protobuf", - ] + select({ - "//bazel/config:brpc_with_glog": ["@com_github_google_glog//:glog"], - "//conditions:default": [], - }) + select({ -- "@bazel_tools//tools/osx:darwin": [":macos_lib"], -+ "@bazel_tools//src/conditions:darwin": [":macos_lib"], - "//conditions:default": [], - }) + select({ - "//bazel/config:brpc_with_boringssl": ["@boringssl//:ssl", "@boringssl//:crypto"], - -diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel -index 4471bad1..d9cc6bd6 100644 ---- a/bazel/config/BUILD.bazel -+++ b/bazel/config/BUILD.bazel -@@ -94,6 +94,8 @@ config_setting( - - config_setting( - name = "darwin", -- values = {"cpu": "darwin"}, -+ constraint_values = [ -+ "@platforms//os:macos", -+ ], - visibility = ["//:__subpkgs__"], - ) -diff --git a/test/BUILD.bazel b/test/BUILD.bazel -index a2eea9cf..d5c7372f 100644 ---- a/test/BUILD.bazel -+++ b/test/BUILD.bazel -@@ -140,7 +140,7 @@ TEST_BUTIL_SOURCES = [ - "bounded_queue_unittest.cc", - "butil_unittest_main.cpp", - ] + select({ -- "@bazel_tools//tools/osx:darwin": [], -+ "@bazel_tools//src/conditions:darwin": [], - "//conditions:default": [ - "test_file_util_linux.cc", - "proc_maps_linux_unittest.cc", -diff --git a/BUILD.bazel b/BUILD.bazel -index 0bdaa4d3..43597f63 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -45,6 +45,10 @@ COPTS = [ - }) + select({ - "//bazel/config:brpc_with_rdma": ["-DBRPC_WITH_RDMA=1"], - "//conditions:default": [""], -+}) + select({ -+ # Force linux aarch to use O1 build -+ "@bazel_tools//src/conditions:linux_aarch64": ["-O1"], -+ "//conditions:default": [""], - }) - - LINKOPTS = [ -diff --git a/src/brpc/versioned_ref_with_id.h b/src/brpc/versioned_ref_with_id.h -index c78f019b..68dda744 100644 ---- a/src/brpc/versioned_ref_with_id.h -+++ b/src/brpc/versioned_ref_with_id.h -@@ -617,7 +617,7 @@ template - std::string VersionedRefWithId::description() const { - std::string result; - result.reserve(128); -- butil::string_appendf(&result, "Socket{id=%" PRIu64, id()); -+ butil::string_appendf(&result, "Socket{id=%d", (int)id()); - result.append(WRAPPER_CALL( - OnDescription, const_cast(static_cast(this)))); - butil::string_appendf(&result, "} (0x%p)", this); diff --git a/bazel/patches/brpc_crypto.patch b/bazel/patches/brpc_crypto.patch deleted file mode 100644 index f6d3ee71..00000000 --- a/bazel/patches/brpc_crypto.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/BUILD.bazel b/BUILD.bazel -index b2a453e0..10eeee74 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -337,7 +337,8 @@ cc_library( - "//conditions:default": [], - }) + select({ - "//bazel/config:brpc_with_boringssl": ["@boringssl//:ssl", "@boringssl//:crypto"], -- "//conditions:default": ["@openssl//:ssl", "@openssl//:crypto"], -+ "//bazel/config:brpc_with_tongsuo": ["@tongsuo//:tongsuo"], -+ "//conditions:default": ["@openssl//:openssl"], - }), - ) - -diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel -index bed04d3b..8049ec3e 100644 ---- a/bazel/config/BUILD.bazel -+++ b/bazel/config/BUILD.bazel -@@ -108,4 +108,10 @@ config_setting( - name = "brpc_with_boringssl", - define_values = {"BRPC_WITH_BORINGSSL": "true"}, - visibility = ["//visibility:public"], --) -+) -+ -+config_setting( -+ name = "brpc_with_tongsuo", -+ define_values = {"BRPC_WITH_TONGSUO": "true"}, -+ visibility = ["//visibility:public"], -+) diff --git a/bazel/patches/brpc_m1.patch b/bazel/patches/brpc_m1.patch deleted file mode 100644 index 32ddf6b2..00000000 --- a/bazel/patches/brpc_m1.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/src/bvar/default_variables.cpp b/src/bvar/default_variables.cpp -index be02c50a..57b4f661 100644 ---- a/src/bvar/default_variables.cpp -+++ b/src/bvar/default_variables.cpp -@@ -449,7 +449,6 @@ static bool read_proc_io(ProcIO* s) { - static pid_t pid = getpid(); - rusage_info_current rusage; - if (proc_pid_rusage(pid, RUSAGE_INFO_CURRENT, (void**)&rusage) != 0) { -- PLOG(WARNING) << "Fail to proc_pid_rusage"; - return false; - } - s->read_bytes = rusage.ri_diskio_bytesread; diff --git a/bazel/patches/leveldb.patch b/bazel/patches/leveldb.patch deleted file mode 100644 index 7f09a409..00000000 --- a/bazel/patches/leveldb.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/util/env_posix.cc b/util/env_posix.cc -index d84cd1e..d7de716 100644 ---- a/util/env_posix.cc -+++ b/util/env_posix.cc -@@ -837,7 +837,7 @@ class SingletonEnv { - public: - SingletonEnv() { - #if !defined(NDEBUG) -- env_initialized_.store(true, std::memory_order::memory_order_relaxed); -+ env_initialized_.store(true, std::memory_order_relaxed); - #endif // !defined(NDEBUG) - static_assert(sizeof(env_storage_) >= sizeof(EnvType), - "env_storage_ will not fit the Env"); -@@ -854,7 +854,7 @@ class SingletonEnv { - - static void AssertEnvNotInitialized() { - #if !defined(NDEBUG) -- assert(!env_initialized_.load(std::memory_order::memory_order_relaxed)); -+ assert(!env_initialized_.load(std::memory_order_relaxed)); - #endif // !defined(NDEBUG) - } - diff --git a/bazel/patches/libtommath.patch b/bazel/patches/libtommath.patch deleted file mode 100644 index 8c8c88a9..00000000 --- a/bazel/patches/libtommath.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index dfbcb0f..72f9a46 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -113,7 +113,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES - OUTPUT_NAME tommath - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} -- PUBLIC_HEADER "${PUBLIC_HEADERS}" -+ PUBLIC_HEADER "${HEADERS}" - ) - - option(COMPILE_LTO "Build with LTO enabled") -diff --git a/tommath_private.h b/tommath_private.h -index d319a1d..5f4446e 100644 ---- a/tommath_private.h -+++ b/tommath_private.h -@@ -17,7 +17,7 @@ - * On Win32 a .def file must be used to specify the exported symbols. - */ - #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32) && !defined(__CYGWIN__) --# define MP_PRIVATE __attribute__ ((visibility ("hidden"))) -+# define MP_PRIVATE - #else - # define MP_PRIVATE - #endif diff --git a/bazel/patches/mcl.patch b/bazel/patches/mcl.patch deleted file mode 100644 index 466d2538..00000000 --- a/bazel/patches/mcl.patch +++ /dev/null @@ -1,123 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f2ee05c5..8fcb4f23 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -134,6 +134,11 @@ endif() - target_compile_options(mcl PRIVATE ${MCL_COMPILE_OPTIONS}) - target_compile_options(mcl_st PRIVATE ${MCL_COMPILE_OPTIONS}) - -+set(TARGET_FLAG "") -+if(DEFINED CMAKE_ANDROID_ARCH_LLVM_TRIPLE) -+ set(TARGET_FLAG "--target=${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}") -+endif() -+ - # set_target_properties(mcl PROPERTIES - # CXX_STANDARD 11 - # CXX_STANDARD_REQUIRED YES -@@ -168,16 +173,16 @@ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT APPLE) - target_sources(mcl_st PRIVATE src/asm/bint-x64-amd64.S) - endif() - else() -- if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") -- message(FATAL_ERROR "requiring clang++. cmake -DCMAKE_CXX_COMPILER=clang++ ..") -- endif() -+ # if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") -+ # message(FATAL_ERROR "requiring clang++. cmake -DCMAKE_CXX_COMPILER=clang++ ..") -+ # endif() - set(BINT_OBJ "${CMAKE_CURRENT_BINARY_DIR}/bint${BIT}.o") - message("bint_obj=" ${BINT_OBJ}) - target_compile_definitions(mcl PUBLIC MCL_BINT_ASM_X64=0) - target_compile_definitions(mcl_st PUBLIC MCL_BINT_ASM_X64=0) - - add_custom_command(OUTPUT ${BINT_OBJ} -- COMMAND ${CMAKE_CXX_COMPILER} -c -o ${BINT_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/bint${BIT}.ll -O3 -fPIC -+ COMMAND clang++ -c -o ${BINT_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/bint${BIT}.ll -O3 -fPIC ${TARGET_FLAG} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_target(gen_bint.o - SOURCES ${BINT_OBJ}) -@@ -210,7 +215,7 @@ elseif(${MCL_USE_LLVM}) - target_compile_definitions(mcl_st PUBLIC MCL_USE_LLVM=1) - - add_custom_command(OUTPUT ${BASE_OBJ} -- COMMAND ${CMAKE_CXX_COMPILER} -c -o ${BASE_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/base${BIT}.ll -O3 -fPIC -+ COMMAND clang++ -c -o ${BASE_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/base${BIT}.ll -O3 -fPIC ${TARGET_FLAG} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_target(gen_base.o - SOURCES ${BASE_OBJ}) -@@ -222,7 +227,7 @@ elseif(${MCL_USE_LLVM}) - endif() - - # use src/msm_avx.cpp on x64 --if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") # Win64 -+# if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") # Win64 - # set(MSM_OBJ "${CMAKE_CURRENT_BINARY_DIR}/msm_avx.obj") - - # add_custom_command(OUTPUT ${MSM_OBJ} -@@ -236,20 +241,20 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") # Win64 - # add_dependencies(mcl_st msm_avx.o) - # target_sources(mcl_st PRIVATE ${MSM_OBJ}) - --elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT APPLE) -- set(MSM_OBJ "${CMAKE_CURRENT_BINARY_DIR}/msm_avx.o") -- -- add_custom_command(OUTPUT ${MSM_OBJ} -- COMMAND ${CMAKE_CXX_COMPILER} -c -o ${MSM_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/msm_avx.cpp ${MCL_COMPILE_OPTIONS} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -mavx512f -mavx512ifma -std=c++11 -fno-exceptions -fno-rtti -DCYBOZU_DONT_USE_STRING -DCYBOZU_DONT_USE_EXCEPTION -DNDEBUG -- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -- add_custom_target(msm_avx.o -- SOURCES ${MSM_OBJ}) -- target_link_libraries(mcl PUBLIC ${MSM_OBJ}) -- add_dependencies(mcl msm_avx.o) -- target_link_libraries(mcl_st PUBLIC ${MSM_OBJ}) -- add_dependencies(mcl_st msm_avx.o) -- target_sources(mcl_st PRIVATE ${MSM_OBJ}) --endif() -+# elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT APPLE) -+# set(MSM_OBJ "${CMAKE_CURRENT_BINARY_DIR}/msm_avx.o") -+ -+# add_custom_command(OUTPUT ${MSM_OBJ} -+# COMMAND ${CMAKE_CXX_COMPILER} -c -o ${MSM_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/msm_avx.cpp ${MCL_COMPILE_OPTIONS} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -mavx512f -mavx512ifma -std=c++11 -fno-exceptions -fno-rtti -DCYBOZU_DONT_USE_STRING -DCYBOZU_DONT_USE_EXCEPTION -DNDEBUG -+# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -+# add_custom_target(msm_avx.o -+# SOURCES ${MSM_OBJ}) -+# target_link_libraries(mcl PUBLIC ${MSM_OBJ}) -+# add_dependencies(mcl msm_avx.o) -+# target_link_libraries(mcl_st PUBLIC ${MSM_OBJ}) -+# add_dependencies(mcl_st msm_avx.o) -+# target_sources(mcl_st PRIVATE ${MSM_OBJ}) -+# endif() - - if(MCL_TEST_WITH_GMP) - if(NOT MSVC) -diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp -index 5bf4bc7b..1da38f1d 100644 ---- a/include/mcl/op.hpp -+++ b/include/mcl/op.hpp -@@ -411,13 +411,7 @@ inline void dump(const std::string& s) - - } } // mcl::fp - --#ifndef MCL_MSM -- #if (/*defined(_WIN64) ||*/ defined(__x86_64__)) && !defined(__APPLE__) && (MCL_SIZEOF_UNIT == 8) -- #define MCL_MSM 1 -- #else -- #define MCL_MSM 0 -- #endif --#endif -+#define MCL_MSM 0 - - #if MCL_MSM == 1 - namespace mcl { namespace msm { -diff --git a/Makefile b/Makefile -index a60dbf59..0d27036b 100644 ---- a/Makefile -+++ b/Makefile -@@ -3,7 +3,8 @@ LIB_DIR?=lib - OBJ_DIR?=obj - EXE_DIR?=bin - MCL_SIZEOF_UNIT?=$(shell expr $(BIT) / 8) --CLANG?=clang++$(LLVM_VER) -+# CLANG?=clang++$(LLVM_VER) -+CLANG=$(CXX) - SRC_SRC=fp.cpp bn_c256.cpp bn_c384.cpp bn_c384_256.cpp bn_c512.cpp she_c256.cpp - TEST_SRC=fp_test.cpp ec_test.cpp fp_util_test.cpp window_method_test.cpp elgamal_test.cpp fp_tower_test.cpp gmp_test.cpp bn_test.cpp bn384_test.cpp glv_test.cpp paillier_test.cpp she_test.cpp vint_test.cpp bn512_test.cpp conversion_test.cpp - TEST_SRC+=bn_c256_test.cpp bn_c384_test.cpp bn_c384_256_test.cpp bn_c512_test.cpp diff --git a/bazel/patches/msgpack.patch b/bazel/patches/msgpack.patch deleted file mode 100644 index 6e755265..00000000 --- a/bazel/patches/msgpack.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/include/msgpack/v1/detail/cpp11_zone.hpp b/include/msgpack/v1/detail/cpp11_zone.hpp -index 2586f275..bf19dd0c 100644 ---- a/include/msgpack/v1/detail/cpp11_zone.hpp -+++ b/include/msgpack/v1/detail/cpp11_zone.hpp -@@ -20,6 +20,11 @@ - #include - #include - -+#if (defined(linux) || defined(__linux) || defined(__linux__)) && \ -+ (defined(__GNUC__) || defined(__GNUG__)) -+// This is a bug of gcc, suppressing false positives. -+#pragma GCC diagnostic ignored "-Wmismatched-new-delete" -+#endif - namespace msgpack { - - /// @cond diff --git a/bazel/patches/protobuf.patch b/bazel/patches/protobuf.patch deleted file mode 100644 index 088b49a0..00000000 --- a/bazel/patches/protobuf.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h -index 1acbf9e1f..ff2f62282 100644 ---- a/src/google/protobuf/wire_format.h -+++ b/src/google/protobuf/wire_format.h -@@ -356,8 +356,9 @@ inline size_t WireFormat::TagSize(int field_number, - inline void WireFormat::VerifyUTF8String(const char* data, int size, - WireFormat::Operation op) { - #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED -- WireFormatLite::VerifyUtf8String( -- data, size, static_cast(op), nullptr); -+ WireFormatLite::VerifyUtf8String(data, size, -+ static_cast(op), -+ /* field_name = */ ""); - #else - // Avoid the compiler warning about unused variables. - (void)data; diff --git a/bazel/sse2neon.BUILD b/bazel/sse2neon.BUILD deleted file mode 100644 index eb69bdd5..00000000 --- a/bazel/sse2neon.BUILD +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2022 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "sse2neon", - hdrs = ["sse2neon.h"], -) diff --git a/bazel/tongsuo.BUILD b/bazel/tongsuo.BUILD deleted file mode 100644 index bb5de9fd..00000000 --- a/bazel/tongsuo.BUILD +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2024 Ant Group Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@yacl//bazel:yacl.bzl", "yacl_configure_make") - -filegroup( - name = "all_srcs", - srcs = glob( - include = ["**"], - exclude = ["*.bazel"], - ), -) - -CONFIGURE_OPTIONS = [ - # fixed openssl work dir for deterministic build. - "--openssldir=/tmp/openssl", - "--libdir=lib", - "no-legacy", - "no-weak-ssl-ciphers", - "no-tests", - "no-shared", - "no-ui-console", - "enable-ntls", # for GM -] - -MAKE_TARGETS = [ - "build_programs", - "install_sw", -] - -yacl_configure_make( - name = "tongsuo", - args = ["-j 4"], - configure_command = "Configure", - configure_in_place = True, - configure_options = CONFIGURE_OPTIONS, - env = select({ - "@platforms//os:macos": { - "AR": "", - }, - "//conditions:default": { - "MODULESDIR": "", - }, - }), - lib_name = "tongsuo", - lib_source = ":all_srcs", - linkopts = ["-ldl"], - # Note that for Linux builds, libssl must come before libcrypto on the linker command-line. - # As such, libssl must be listed before libcrypto - out_static_libs = [ - "libssl.a", - "libcrypto.a", - ], - targets = MAKE_TARGETS, - visibility = ["//visibility:public"], -) diff --git a/yacl/crypto/hash/blake3_test.cc b/yacl/crypto/hash/blake3_test.cc index 64f170ba..542e9ea5 100644 --- a/yacl/crypto/hash/blake3_test.cc +++ b/yacl/crypto/hash/blake3_test.cc @@ -53,7 +53,9 @@ TestData test_data_blake3 = { TEST(Blake3HashTest, TestVector1) { Blake3Hash blake3; - std::string vector_bytes = absl::HexStringToBytes(test_data_blake3.vector1); + std::string vector_bytes; + + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.vector1, &vector_bytes)); std::vector hash = blake3.Update(vector_bytes).CumulativeHash(); @@ -64,7 +66,8 @@ TEST(Blake3HashTest, TestVector1) { TEST(Blake3HashTest, TestVector2) { Blake3Hash blake3; - std::string vector_bytes = absl::HexStringToBytes(test_data_blake3.vector2); + std::string vector_bytes; + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.vector2, &vector_bytes)); std::vector hash = blake3.Update(vector_bytes).CumulativeHash(); @@ -77,8 +80,10 @@ TEST(Blake3HashTest, TestVector2) { // a clean state, allowing a new hash operation to take place. TEST(Blake3HashTest, ResetBetweenUpdates) { Blake3Hash blake3; - std::string vector1_bytes = absl::HexStringToBytes(test_data_blake3.vector1); - std::string vector2_bytes = absl::HexStringToBytes(test_data_blake3.vector2); + std::string vector1_bytes; + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.vector1, &vector1_bytes)); + std::string vector2_bytes; + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.vector2, &vector2_bytes)); std::vector hash = blake3.Update(vector1_bytes) .Reset() .Update(vector2_bytes) @@ -92,8 +97,10 @@ TEST(Blake3HashTest, ResetBetweenUpdates) { // calls to Update. TEST(Blake3HashTest, MultipleUpdates) { Blake3Hash blake3; - std::string vector1_bytes = absl::HexStringToBytes(test_data_blake3.vector1); - std::string suffix_bytes = absl::HexStringToBytes(test_data_blake3.suffix); + std::string vector1_bytes; + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.vector1, &vector1_bytes)); + std::string suffix_bytes; + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.suffix, &suffix_bytes)); std::vector result = blake3.Update(vector1_bytes).CumulativeHash(); EXPECT_EQ(absl::BytesToHexString( @@ -115,8 +122,9 @@ TEST(Blake3HashTest, CustomOutLength) { for (size_t i = 0; i <= (8 * BLAKE3_OUT_LEN); i++) { Blake3Hash blake3(i); - std::string vector1_bytes = - absl::HexStringToBytes(test_data_blake3.vector1); + std::string vector1_bytes; + ASSERT_TRUE( + absl::HexStringToBytes(test_data_blake3.vector1, &vector1_bytes)); // Shorter outputs are prefixes of longer ones. // reference @@ -145,7 +153,8 @@ TEST(Blake3HashTest, MaximumLength) { Blake3Hash blake3(max_size); - std::string vector1_bytes = absl::HexStringToBytes(test_data_blake3.vector1); + std::string vector1_bytes; + ASSERT_TRUE(absl::HexStringToBytes(test_data_blake3.vector1, &vector1_bytes)); auto len = std::min(max_size, static_cast(BLAKE3_OUT_LEN));