From b0a94650de144dbd73a09b0146259914fc9fd670 Mon Sep 17 00:00:00 2001
From: tongke6 <124763920+tongke6@users.noreply.github.com>
Date: Thu, 12 Dec 2024 21:42:11 +0800
Subject: [PATCH] Fix build on macos with apple M1 chip

* Fix issue https://github.com/apache/brpc/issues/2845
---
 BUILD.bazel  |  6 +++---
 MODULE.bazel | 10 ++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/BUILD.bazel b/BUILD.bazel
index 0e2e66edd2..ce85ab04cc 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -57,7 +57,7 @@ LINKOPTS = [
     "-pthread",
     "-ldl",
 ] + select({
-    "@bazel_tools//tools/osx:darwin_x86_64": [
+    "@bazel_tools//src/conditions:darwin": [
         "-framework CoreFoundation",
         "-framework CoreGraphics",
         "-framework CoreData",
@@ -226,7 +226,7 @@ BUTIL_SRCS = [
     "src/butil/recordio.cc",
     "src/butil/popen.cpp",
 ] + select({
-    "@bazel_tools//tools/osx:darwin_x86_64": [
+    "@bazel_tools//src/conditions:darwin": [
         "src/butil/time/time_mac.cc",
         "src/butil/mac/scoped_mach_port.cc",
     ],
@@ -341,7 +341,7 @@ cc_library(
         "//bazel/config:brpc_with_glog": ["@com_github_google_glog//:glog"],
         "//conditions:default": [],
     }) + select({
-        "@bazel_tools//tools/osx:darwin_x86_64": [":macos_lib"],
+        "@bazel_tools//src/conditions:darwin": [":macos_lib"],
         "//conditions:default": [],
     }) + select({
         "//bazel/config:brpc_with_boringssl": ["@boringssl//:ssl", "@boringssl//:crypto"],
diff --git a/MODULE.bazel b/MODULE.bazel
index e53146aefb..5b8bd166fd 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -12,13 +12,23 @@ bazel_dep(name = 'protobuf', version = '27.3', repo_name = 'com_google_protobuf'
 bazel_dep(name = 'gflags', version = '2.2.2', repo_name = 'com_github_gflags_gflags')
 bazel_dep(name = 'glog', version = '0.5.0', repo_name = 'com_github_google_glog')
 bazel_dep(name = 'platforms', version = '0.0.4')
+bazel_dep(name = "apple_support", version = "1.17.1")
 bazel_dep(name = 'rules_cc', version = '0.0.1')
 bazel_dep(name = 'rules_proto', version = '4.0.0')
 bazel_dep(name = 'zlib', version = '1.2.13', repo_name = 'com_github_madler_zlib')
 
 # --registry=https://baidu.github.io/babylon/registry
 bazel_dep(name = 'leveldb', version = '1.23', repo_name = 'com_github_google_leveldb')
+single_version_override(
+    module_name = "leveldb",
+    registry = "https://raw.githubusercontent.com/secretflow/bazel-registry/main",
+)
 bazel_dep(name = 'openssl', version = '3.3.2')
+single_version_override(
+    module_name = "openssl",
+    version = "3.3.2.bcr.1",
+    registry = "https://raw.githubusercontent.com/secretflow/bazel-registry/main",
+)
 bazel_dep(name = 'thrift', version = '0.21.0', repo_name = 'org_apache_thrift')
 
 # test only