Skip to content

Commit

Permalink
Merge pull request #422 from j2kun:openfhe-e2e-test-harness
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 604368990
  • Loading branch information
copybara-github committed Feb 5, 2024
2 parents 3d16949 + 5a94355 commit 8093076
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 0 deletions.
26 changes: 26 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,29 @@ git_repository(
remote = "https://github.com/google/or-tools.git",
shallow_since = "1647023481 +0100",
)

# OpenFHE backend and dependencies
git_repository(
name = "cereal",
build_file = "//bazel/openfhe:cereal.BUILD",
commit = "ebef1e929807629befafbb2918ea1a08c7194554",
remote = "https://github.com/USCiLab/cereal.git",
)

git_repository(
name = "rapidjson",
build_file = "//bazel/openfhe:rapidjson.BUILD",
commit = "f54b0e47a08782a6131cc3d60f94d038fa6e0a51",
remote = "https://github.com/Tencent/rapidjson.git",
)

git_repository(
name = "openfhe",
build_file = "//bazel/openfhe:openfhe.BUILD",
# TODO(#424): update to v1.1.3, which fixes issues with scheme switching
# that show up when run with sanitizers enabled
# Currently v1.1.2, 2023-12-26
commit = "b2869aef5cf61afd364b3eaea748dcc8a7020b9c",
patches = ["@heir//bazel/openfhe:add_config_core.patch"],
remote = "https://github.com/openfheorg/openfhe-development.git",
)
7 changes: 7 additions & 0 deletions bazel/openfhe/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This build file is necessary to mark this directory as a subpackage for bazel
# to have access to the files.

package(
default_applicable_licenses = ["@heir//:license"],
default_visibility = ["//visibility:public"],
)
13 changes: 13 additions & 0 deletions bazel/openfhe/add_config_core.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/core/include/config_core.h
+++ src/core/include/config_core.h
@@ -0,0 +1,10 @@
+// This file is normally generated by CMake; we check it in for bazel builds.
+
+#define WITH_BE2
+#define WITH_BE4
+/* #undef WITH_NTL */
+/* #undef WITH_TCM */
+
+#define HAVE_INT64 TRUE
+#define NATIVEINT 64
+#define CKKS_M_FACTOR 1
19 changes: 19 additions & 0 deletions bazel/openfhe/cereal.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package(
default_visibility = ["//visibility:public"],
features = ["-use_header_modules"], # Incompatible with -fexceptions.
)

licenses(["notice"])

cc_library(
name = "cereal",
copts = ["-fexceptions"],
includes = ["include"],
textual_hdrs = glob([
"include/**/*.hpp",
"include/**/*.h",
]),
deps = [
"@rapidjson",
],
)
96 changes: 96 additions & 0 deletions bazel/openfhe/openfhe.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# BUILD file for a bazel-native OpenFHE build

package(
default_visibility = ["//visibility:public"],
features = [
"-layering_check", # Incompatible with `#include "gtest/gtest.h"`
"-use_header_modules", # Incompatible with -fexceptions.
],
)

licenses(["notice"])

OPENFHE_VERSION_MAJOR = 1

OPENFHE_VERSION_MINOR = 11

OPENFHE_VERSION_PATCH = 3

OPENFHE_VERSION = "{}.{}.{}".format(OPENFHE_VERSION_MAJOR, OPENFHE_VERSION_MINOR, OPENFHE_VERSION_PATCH)

OPENFHE_COPTS = [
"-Wno-non-virtual-dtor",
"-Wno-shift-op-parentheses",
"-Wno-unused-private-field",
"-fexceptions",
]

OPENFHE_DEFINES = [
"MATHBACKEND=2",
"OMP_NUM_THREADS=1",
"OPENFHE_VERSION=" + OPENFHE_VERSION,
]

cc_library(
name = "core",
srcs = glob([
"src/core/lib/**/*.c",
"src/core/lib/**/*.cpp",
]),
copts = OPENFHE_COPTS + [
# /utils/blockAllocator/blockAllocator.cpp has misaligned-pointer-use
"-fno-sanitize=alignment",
],
defines = OPENFHE_DEFINES,
includes = [
"src/core/include",
"src/core/lib",
],
textual_hdrs = glob([
"src/core/include/**/*.h",
"src/core/lib/**/*.cpp",
]),
deps = ["@cereal"],
)

cc_library(
name = "binfhe",
srcs = glob([
"src/binfhe/lib/**/*.c",
"src/binfhe/lib/**/*.cpp",
]),
copts = OPENFHE_COPTS,
defines = OPENFHE_DEFINES,
includes = [
"src/binfhe/include",
"src/binfhe/lib",
],
textual_hdrs = glob(["src/binfhe/include/**/*.h"]),
deps = [
"@openfhe//:core",
],
)

cc_library(
name = "pke",
srcs = glob([
"src/pke/lib/**/*.cpp",
]),
copts = OPENFHE_COPTS + [
"-Wno-vla-extension",
],
defines = OPENFHE_DEFINES,
includes = [
"src/pke/include",
"src/pke/lib",
],
textual_hdrs = glob([
"src/pke/include/**/*.h",
"src/pke/lib/**/*.cpp",
]),
deps = [
"@cereal",
"@openfhe//:binfhe",
"@openfhe//:core",
],
)
48 changes: 48 additions & 0 deletions bazel/openfhe/rapidjson.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package(
default_visibility = ["//visibility:public"],
features = ["-use_header_modules"], # Incompatible with -fexceptions.
)

licenses(["notice"])

cc_library(
name = "rapidjson",
srcs = [
"include/rapidjson/internal/biginteger.h",
"include/rapidjson/internal/diyfp.h",
"include/rapidjson/internal/dtoa.h",
"include/rapidjson/internal/ieee754.h",
"include/rapidjson/internal/itoa.h",
"include/rapidjson/internal/meta.h",
"include/rapidjson/internal/pow10.h",
"include/rapidjson/internal/regex.h",
"include/rapidjson/internal/stack.h",
"include/rapidjson/internal/strfunc.h",
"include/rapidjson/internal/strtod.h",
"include/rapidjson/internal/swap.h",
],
hdrs = [
"include/rapidjson/allocators.h",
"include/rapidjson/document.h",
"include/rapidjson/encodedstream.h",
"include/rapidjson/encodings.h",
"include/rapidjson/error/en.h",
"include/rapidjson/error/error.h",
"include/rapidjson/filereadstream.h",
"include/rapidjson/filewritestream.h",
"include/rapidjson/fwd.h",
"include/rapidjson/istreamwrapper.h",
"include/rapidjson/memorybuffer.h",
"include/rapidjson/memorystream.h",
"include/rapidjson/ostreamwrapper.h",
"include/rapidjson/pointer.h",
"include/rapidjson/prettywriter.h",
"include/rapidjson/rapidjson.h",
"include/rapidjson/reader.h",
"include/rapidjson/schema.h",
"include/rapidjson/stream.h",
"include/rapidjson/stringbuffer.h",
"include/rapidjson/writer.h",
],
includes = ["include"],
)

0 comments on commit 8093076

Please sign in to comment.