From 6edb3018f9996f6ebbef91cd59c1bcbb44710e12 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 30 Mar 2020 18:58:27 -0700 Subject: [PATCH] Add configurations for BLS builds (#5254) * Add configurations for BLS builds * Merge refs/heads/master into bls-configurations --- third_party/herumi/bls_eth_go_binary.BUILD | 36 ++++++++++++++++++++-- third_party/herumi/mcl.BUILD | 15 --------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/third_party/herumi/bls_eth_go_binary.BUILD b/third_party/herumi/bls_eth_go_binary.BUILD index 31e31f195d8..be8738ccb9d 100644 --- a/third_party/herumi/bls_eth_go_binary.BUILD +++ b/third_party/herumi/bls_eth_go_binary.BUILD @@ -1,8 +1,16 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +config_setting( + name = "use_gmp", + values = {"define": "BLS_USE_GMP=true"}, +) + +config_setting( + name = "use_openssl", + values = {"define": "BLS_USE_OPENSSL=true"}, +) + OPTS = [ - "-DMCL_USE_VINT", - "-DMCL_DONT_USE_OPENSSL", "-DMCL_LLVM_BMI2=0", "-DMCL_USE_LLVM=1", "-DMCL_VINT_FIXED_BUFFER", @@ -12,7 +20,19 @@ OPTS = [ "-DCYBOZU_DONT_USE_STRING", "-DBLS_SWAP_G", "-DBLS_ETH", -] +] + select({ + ":use_gmp": [], + "//conditions:default": [ + "-DMCL_USE_VINT", + ], +}) + select({ + ":use_openssl": [], + "//conditions:default": [ + "-DMCL_DONT_USE_OPENSSL", + ], +}) + + genrule( name = "base64_ll", @@ -55,6 +75,16 @@ cc_library( copts = OPTS + [ "-std=c++03", ], + linkopts = select({ + ":use_gmp": ["-lgmp"], + "//conditions:default": [], + }) + select({ + ":use_openssl": [ + "-lssl", + "-lcrypto" + ], + "//conditions:default": [], + }) ) cc_library( diff --git a/third_party/herumi/mcl.BUILD b/third_party/herumi/mcl.BUILD index a9dbaa01c27..54cc347b3b7 100644 --- a/third_party/herumi/mcl.BUILD +++ b/third_party/herumi/mcl.BUILD @@ -1,18 +1,5 @@ package(default_visibility = ["//visibility:public"]) -MCL_OPTS = [ - "-DMCL_USE_VINT", - "-DMCL_DONT_USE_OPENSSL", - "-DMCL_LLVM_BMI2=0", - "-DMCL_USE_LLVM=1", - "-DMCL_VINT_FIXED_BUFFER", - "-DMCL_SIZEOF_UNIT=8", - "-DMCL_MAX_BIT_SIZE=384", - "-DCYBOZU_DONT_USE_EXCEPTION", - "-DCYBOZU_DONT_USE_STRING", - "-std=c++03 ", -] - cc_library( name = "fp", srcs = [ @@ -40,7 +27,6 @@ cc_library( "src/proto.hpp", "src/low_func_llvm.hpp", ], - copts = MCL_OPTS, ) cc_library( @@ -63,7 +49,6 @@ cc_library( "include/mcl/operator.hpp", ], includes = ["include"], - copts = MCL_OPTS, ) # src_gen is a tool to generate some llvm assembly language file.