Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ build:linux --linkopt="-fuse-ld=lld"
build:linux --linkopt="-Wl,-no-pie"

# macos specific options
# openmp is not supported in apple clang
build:macos --@openfhe//:enable_openmp=False

build:macos --no@fuzztest//fuzztest:use_riegeli

# MacOS arm64 config
build:macos_arm64 --cpu=darwin_arm64
build:macos_arm64 --macos_minimum_os=11.0
# openmp is not supported in apple clang
build:macos_arm64 --@openfhe//:enable_openmp=False


# run with --config=asan to enable
build:asan --strip=never
Expand Down
21 changes: 3 additions & 18 deletions .github/workflows/build_and_test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,10 @@ jobs:
with:
path: |
~/.cache/bazel
key: ${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}-${{ hashFiles('bazel/extensions.bzl') }}
key: ${{ runner.os }}-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}-${{ hashFiles('bazel/extensions.bzl') }}
restore-keys: |
${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}-${{ hashFiles('bazel/extensions.bzl') }}
${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}-

- name: Install rust
run: brew install rust

- name: Install OpenMP
run: brew install libomp

- name: Set OpenMP environment variables
run: |
echo "LDFLAGS=-L$(brew --prefix libomp)/lib" >> "$GITHUB_ENV"
echo "CPPFLAGS=-I$(brew --prefix libomp)/include" >> "$GITHUB_ENV"

- name: Bazel debug info
run: |
bazel cquery --output=starlark --starlark:expr="str(providers(target))" @bazel_tools//tools/cpp:current_cc_toolchain | sed 's/,/\n/g'
${{ runner.os }}-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}-${{ hashFiles('bazel/extensions.bzl') }}
${{ runner.os }}-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}-

- name: "Run `bazel build`"
run: |
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/build_options_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
- "opt"
- "fastbuild"
- "dbg"
enable_openmp:
- 0
- 1

enable_yosys:
- 0
- 1
Expand All @@ -36,7 +34,6 @@ jobs:
run: |
read -r -a BAZEL_CONFIGS <<< "$BAZEL_CONFIG_FLAG"
bazel build --incompatible_strict_action_env -c ${{ matrix.compilation_mode }} \
--//:enable_openmp=${{ matrix.enable_openmp }} \
--//:enable_yosys=${{ matrix.enable_yosys }} \
"${BAZEL_CONFIGS[@]}" \
--remote_header=x-buildbuddy-api-key="$BUILDBUDDY_API_KEY" \
Expand All @@ -46,7 +43,6 @@ jobs:
run: |
read -r -a BAZEL_CONFIGS <<< "$BAZEL_CONFIG_FLAG"
bazel test --incompatible_strict_action_env -c ${{ matrix.compilation_mode }} \
--//:enable_openmp=${{ matrix.enable_openmp }} \
--//:enable_yosys=${{ matrix.enable_yosys }} \
"${BAZEL_CONFIGS[@]}" \
--remote_header=x-buildbuddy-api-key="$BUILDBUDDY_API_KEY" \
Expand Down
24 changes: 1 addition & 23 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,9 @@ package_group(
# copybara: fuzztest_ci_invocation

# Disables deps for CI tools and tests.
# use by passing `--//:enable_openmp=0` or `--//:enable_yosys=0`
# use by passing `--//:enable_yosys=0`
# to `bazel build` or `bazel test`

# OpenMP
string_flag(
name = "enable_openmp",
build_setting_default = "1",
)

config_setting(
name = "config_enable_openmp",
flag_values = {
":enable_openmp": "1",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "config_disable_openmp",
flag_values = {
":enable_openmp": "0",
},
visibility = ["//visibility:public"],
)

# Yosys
string_flag(
name = "enable_yosys",
Expand Down
13 changes: 5 additions & 8 deletions bazel/openfhe/copts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

OPENMP_LINKOPTS = []

OPENMP_COPTS = select({
"@openfhe//:config_enable_openmp": [
"-fopenmp",
"-Xpreprocessor",
"-Wno-unused-command-line-argument",
],
"//conditions:default": [],
})
OPENMP_COPTS = [
"-fopenmp",
"-Xpreprocessor",
"-Wno-unused-command-line-argument",
]
102 changes: 76 additions & 26 deletions patches/openfhe.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,67 @@
--- a/BUILD
+++ b/BUILD
@@ -59,21 +59,7 @@
},
@@ -10,30 +10,15 @@
],
)


-bool_flag(
- name = "enable_openmp",
- build_setting_default = True,
-)
-
-config_setting(
- name = "config_enable_openmp",
- flag_values = {":enable_openmp": "True"},
-)

-config_setting(
- name = "config_disable_openmp",
- flag_values = {":enable_openmp": "False"},
-)

OPENFHE_VERSION = "1.4.2"

OPENFHE_DEFINES = [
"MATHBACKEND=" + str(MATHBACKEND),
"OPENFHE_VERSION=" + OPENFHE_VERSION,
-] + select({
- "//:config_enable_openmp": ["PARALLEL"],
- "//conditions:default": [],
-})
+ "PARALLEL",
+]

OPENFHE_COPTS = [
"-Wno-non-virtual-dtor",
@@ -43,46 +28,15 @@
"-std=c++17",
]

-config_setting(
- name = "clang_openmp",
- flag_values = {
- "@rules_cc//cc/compiler:compiler": "clang",
- "//:enable_openmp": "True",
- },
-)
-
-config_setting(
- name = "gcc_openmp",
- flag_values = {
- "@rules_cc//cc/compiler:compiler": "gcc",
- "//:enable_openmp": "True",
- },
-)
+OPENMP_LINKOPTS = []

-_OPENMP_CLANG_LINKOPTS = [
- "-fopenmp",
+OPENMP_COPTS = [
"-fopenmp",
- "-lomp",
-]
-
+ "-Xpreprocessor",
+ "-Wno-unused-command-line-argument",
]

-_OPENMP_GCC_LINKOPTS = [
- "-fopenmp",
- "-lgomp",
Expand All @@ -19,46 +72,43 @@
- "//:gcc_openmp": _OPENMP_GCC_LINKOPTS,
- "//conditions:default": [],
-})
+OPENMP_LINKOPTS = []

OPENMP_COPTS = select({
"//:config_enable_openmp": [
@@ -84,6 +70,11 @@
"//conditions:default": [],
})

+OPENMP_DEPS = select({
+ "//:config_enable_openmp": ["@hermetic_llvm//openmp:libomp"],
+ "//conditions:default": [],
+})
+
-
-OPENMP_COPTS = select({
- "//:config_enable_openmp": [
- "-fopenmp",
- "-Xpreprocessor",
- "-Wno-unused-command-line-argument",
- ],
- "//conditions:default": [],
-})
+OPENMP_DEPS = ["@hermetic_llvm//openmp:libomp"]

genrule(
name = "generate_config_core_h",
outs = ["src/core/include/config_core.h"],
@@ -137,7 +128,7 @@
@@ -139,7 +93,7 @@
":generate_config_core_h",
":prng",
"@cereal",
- ],
+ ] + OPENMP_DEPS,
)

cc_library(
@@ -156,7 +147,7 @@
@@ -159,7 +113,7 @@
deps = [
":core",
":generate_config_core_h",
- ],
+ ] + OPENMP_DEPS,
)

cc_library(
@@ -182,7 +173,7 @@
@@ -186,7 +140,7 @@
":core",
":generate_config_core_h",
"@cereal",
- ],
+ ] + OPENMP_DEPS,
)

# Generates a shared library that can be shipped with the python frontend.
Loading