Skip to content

Commit 1782f0a

Browse files
thiiphilwo
authored andcommitted
Patch grpc to fix cares selecting the wrong source when building for darwin_arm64 cpu.
This should use constraints instead of cpu flags, but that should be fixed on the grpc repository. I just added new `config_setting`s here to keep the patch size small. This should allow building a Bazel binary for Apple Silicon hardware from an Intel Mac with: ``` USE_BAZEL_VERSION=last_green bazel build -c opt --cpu=darwin_arm64 //src:bazel ``` (This needs last green Bazel because we need recent changes to `@bazel_tools` which needs a Bazel release.) Closes #12594. Signed-off-by: Philipp Wollermann <[email protected]>
1 parent 82ac8e9 commit 1782f0a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

third_party/grpc/grpc_1.32.0.patch

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Date: Wed Jun 3 15:35:31 2020 +0200
88
libraries
99
- Add bazel mirror URL for upb and cares
1010
- Redirect zlib to @//third_party/zlib
11+
- Add darwin_arm64 and darwin_arm64e config settings to allow
12+
building for Apple Silicon
1113

1214
diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
1315
index 7bb6b8bdb9..7644107b70 100644
@@ -88,3 +90,33 @@ index 4c1dfad2e8..f63c54ddef 100644
8890
- apple_rules_dependencies()
8991
-
9092
- apple_support_dependencies()
93+
diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD
94+
index c047f0c515..7c24fbc617 100644
95+
--- a/third_party/cares/cares.BUILD
96+
+++ b/third_party/cares/cares.BUILD
97+
@@ -10,6 +10,16 @@ config_setting(
98+
values = {"cpu": "darwin_x86_64"},
99+
)
100+
101+
+config_setting(
102+
+ name = "darwin_arm64",
103+
+ values = {"cpu": "darwin_arm64"},
104+
+)
105+
+
106+
+config_setting(
107+
+ name = "darwin_arm64e",
108+
+ values = {"cpu": "darwin_arm64e"},
109+
+)
110+
+
111+
config_setting(
112+
name = "windows",
113+
values = {"cpu": "x64_windows"},
114+
@@ -99,6 +109,8 @@ copy_file(
115+
":watchos_arm64_32": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
116+
":darwin": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
117+
":darwin_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
118+
+ ":darwin_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
119+
+ ":darwin_arm64e": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
120+
":windows": "@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h",
121+
":android": "@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h",
122+
"//conditions:default": "@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h",

0 commit comments

Comments
 (0)