From 9142d3ed12d8653c7657316f70996e78b22b732f Mon Sep 17 00:00:00 2001 From: Jamie Cui Date: Wed, 8 Jan 2025 00:10:45 +0800 Subject: [PATCH] chore(build): finalize cmake and bazel support --- .bazelrc | 6 ++++++ bazel/FourQlib.BUILD | 1 + bazel/libgmp.BUILD | 5 +++++ cmake/deps/fourq.cmake | 20 ++++++++++++-------- yacl/crypto/aes/BUILD.bazel | 16 ++-------------- yacl/crypto/ecc/FourQlib/FourQ_group.h | 2 +- yacl/crypto/rand/drbg/BUILD.bazel | 4 ++-- yacl/crypto/rand/entropy_source/BUILD.bazel | 4 ++-- yacl/kernel/algorithms/ferret_ote.h | 2 +- yacl/kernel/algorithms/ferret_ote_un.h | 2 +- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.bazelrc b/.bazelrc index f2143a0..bffe844 100644 --- a/.bazelrc +++ b/.bazelrc @@ -41,6 +41,12 @@ build:macos --macos_minimum_os=13.0 build:macos --host_macos_minimum_os=13.0 build:macos --action_env MACOSX_DEPLOYMENT_TARGET=13.0 +# HACK https://github.com/bazelbuild/apple_support +build --enable_platform_specific_config +build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain +build:macos --crosstool_top=@local_config_apple_cc//:toolchain +build:macos --host_crosstool_top=@local_config_apple_cc//:toolchain + build:asan --features=asan build:ubsan --features=ubsan diff --git a/bazel/FourQlib.BUILD b/bazel/FourQlib.BUILD index a8738b3..c320d93 100644 --- a/bazel/FourQlib.BUILD +++ b/bazel/FourQlib.BUILD @@ -62,6 +62,7 @@ make( }), lib_source = ":all_srcs", out_static_libs = ["libFourQ.a"], + # FIXME try to install header in include/fourq/*.h targets = [ "libFourQ", "install", diff --git a/bazel/libgmp.BUILD b/bazel/libgmp.BUILD index cab69fc..a57c5be 100644 --- a/bazel/libgmp.BUILD +++ b/bazel/libgmp.BUILD @@ -30,6 +30,11 @@ configure_make_variant( name = "gmp", configure_options = ["--with-pic"], copts = ["-w"], + # HACK fix macos build + # see: https://github.com/bazel-contrib/rules_foreign_cc/issues/338 + env = { + "AR": "", + }, lib_name = "libgmp", lib_source = ":sources", out_static_libs = [ diff --git a/cmake/deps/fourq.cmake b/cmake/deps/fourq.cmake index a86e4a4..64da6f3 100644 --- a/cmake/deps/fourq.cmake +++ b/cmake/deps/fourq.cmake @@ -32,14 +32,18 @@ ExternalProject_Add(fourq COMMAND ${CMAKE_MAKE_PROGRAM} PREFIX=${CMAKE_THIRDPARTY_PREFIX} -C FourQ_64bit_and_portable install - COMMAND - mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/FourQ.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ - COMMAND - mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/FourQ_api.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ - COMMAND - mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/FourQ_internal.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ - COMMAND - mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/random.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ + # + # FIXME wait for bazel try to install header in include/fourq/*.h + # see: fourq.BUILD + # + # COMMAND + # mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/FourQ.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ + # COMMAND + # mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/FourQ_api.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ + # COMMAND + # mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/FourQ_internal.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ + # COMMAND + # mv ${CMAKE_THIRDPARTY_INCLUDEDIR}/random.h ${CMAKE_THIRDPARTY_INCLUDEDIR}/fourq/ EXCLUDE_FROM_ALL true LOG_DOWNLOAD On LOG_CONFIGURE On diff --git a/yacl/crypto/aes/BUILD.bazel b/yacl/crypto/aes/BUILD.bazel index 1da62b2..e9f031b 100644 --- a/yacl/crypto/aes/BUILD.bazel +++ b/yacl/crypto/aes/BUILD.bazel @@ -12,22 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:yacl.bzl", "AES_COPT_FLAGS", "yacl_cc_binary", "yacl_cc_library", "yacl_cc_test") +load("//bazel:yacl.bzl", "AES_COPT_FLAGS", "yacl_cc_library", "yacl_cc_test") package(default_visibility = ["//visibility:public"]) -yacl_cc_binary( - name = "aes_bench", - srcs = ["aes_bench.cc"], - copts = AES_COPT_FLAGS, - deps = [ - ":aes_opt", - "//yacl/crypto/rand", - "//yacl/crypto/tools:prg", - "@com_github_google_benchmark//:benchmark_main", - ], -) - yacl_cc_library( name = "aes_intrinsics", srcs = [ @@ -35,8 +23,8 @@ yacl_cc_library( ], copts = AES_COPT_FLAGS, deps = [ - "//yacl/base:secparam", "//yacl/base:int128", + "//yacl/base:secparam", ] + select({ "@platforms//cpu:aarch64": [ "@com_github_dltcollab_sse2neon//:sse2neon", diff --git a/yacl/crypto/ecc/FourQlib/FourQ_group.h b/yacl/crypto/ecc/FourQlib/FourQ_group.h index cf42c43..a4ddb46 100644 --- a/yacl/crypto/ecc/FourQlib/FourQ_group.h +++ b/yacl/crypto/ecc/FourQlib/FourQ_group.h @@ -14,7 +14,7 @@ #pragma once -#include "fourq/FourQ_internal.h" +#include "FourQ_internal.h" #include "yacl/crypto/ecc/group_sketch.h" diff --git a/yacl/crypto/rand/drbg/BUILD.bazel b/yacl/crypto/rand/drbg/BUILD.bazel index a0265ae..a1053e3 100644 --- a/yacl/crypto/rand/drbg/BUILD.bazel +++ b/yacl/crypto/rand/drbg/BUILD.bazel @@ -87,8 +87,8 @@ yacl_cc_library( ) yacl_cc_test( - name = "factory_test", - srcs = ["factory_test.cc"], + name = "drbg_test", + srcs = ["drbg_test.cc"], deps = [ ":drbg", ], diff --git a/yacl/crypto/rand/entropy_source/BUILD.bazel b/yacl/crypto/rand/entropy_source/BUILD.bazel index a7c5258..fb16878 100644 --- a/yacl/crypto/rand/entropy_source/BUILD.bazel +++ b/yacl/crypto/rand/entropy_source/BUILD.bazel @@ -75,9 +75,9 @@ yacl_cc_library( ) yacl_cc_test( - name = "factory_test", + name = "entropy_source_test", srcs = [ - "factory_test.cc", + "entropy_source_test.cc", ], deps = [ ":entropy_source", diff --git a/yacl/kernel/algorithms/ferret_ote.h b/yacl/kernel/algorithms/ferret_ote.h index 8e32bd6..8e5a703 100644 --- a/yacl/kernel/algorithms/ferret_ote.h +++ b/yacl/kernel/algorithms/ferret_ote.h @@ -22,7 +22,7 @@ #include "yacl/kernel/type/ot_store_utils.h" #include "yacl/math/gadget.h" #include "yacl/base/secparam.h" -#include "yacl/utils/cuckoo_index.h" +#include "yacl/crypto/tools/cuckoo_index.h" /* submodules */ #include "yacl/kernel/algorithms/ferret_ote_rn.h" diff --git a/yacl/kernel/algorithms/ferret_ote_un.h b/yacl/kernel/algorithms/ferret_ote_un.h index 860ea43..fd2e0a8 100644 --- a/yacl/kernel/algorithms/ferret_ote_un.h +++ b/yacl/kernel/algorithms/ferret_ote_un.h @@ -21,7 +21,7 @@ #include "yacl/math/gadget.h" #include "yacl/base/secparam.h" -#include "yacl/utils/cuckoo_index.h" +#include "yacl/crypto/tools/cuckoo_index.h" /* submodules */ #include "yacl/crypto/tools/rp.h"