From 8b922bb673b0ead20f4e7c54ff5e9e8a2b1acb0b Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Thu, 9 Jul 2026 14:49:32 -0700 Subject: [PATCH 1/2] Remove OpenMP gating Fixes #3103 --- .bazelrc | 6 +- .github/workflows/build_options_matrix.yml | 6 +- BUILD.bazel | 24 +---- bazel/openfhe/copts.bzl | 13 +-- patches/openfhe.patch | 102 +++++++++++++++------ 5 files changed, 85 insertions(+), 66 deletions(-) diff --git a/.bazelrc b/.bazelrc index 732df8e9be..a2e38a7469 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 diff --git a/.github/workflows/build_options_matrix.yml b/.github/workflows/build_options_matrix.yml index 032e029fd0..3bb23b3339 100644 --- a/.github/workflows/build_options_matrix.yml +++ b/.github/workflows/build_options_matrix.yml @@ -16,9 +16,7 @@ jobs: - "opt" - "fastbuild" - "dbg" - enable_openmp: - - 0 - - 1 + enable_yosys: - 0 - 1 @@ -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" \ @@ -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" \ diff --git a/BUILD.bazel b/BUILD.bazel index f95520f86a..32af6a95ab 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", diff --git a/bazel/openfhe/copts.bzl b/bazel/openfhe/copts.bzl index 527c06c865..1c9336c30b 100644 --- a/bazel/openfhe/copts.bzl +++ b/bazel/openfhe/copts.bzl @@ -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", +] diff --git a/patches/openfhe.patch b/patches/openfhe.patch index e26644de70..336181d91d 100644 --- a/patches/openfhe.patch +++ b/patches/openfhe.patch @@ -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", @@ -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. From 08f8fa6ba8f6786222036203639283414126a97c Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Thu, 9 Jul 2026 14:51:57 -0700 Subject: [PATCH 2/2] try simplifying the macos CI --- .github/workflows/build_and_test_macos.yml | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build_and_test_macos.yml b/.github/workflows/build_and_test_macos.yml index b76a80ea75..e993872110 100644 --- a/.github/workflows/build_and_test_macos.yml +++ b/.github/workflows/build_and_test_macos.yml @@ -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: |