Skip to content

Commit d358a8c

Browse files
committed
build(bazel): add experimental darwin arm64 platform
Registers the zig darwin cc toolchain, an aarch64-apple-darwin rust toolchain, and a //:darwin_arm64 platform. Toolchain resolution works and pure-Rust rlibs cross-compile from Linux; crates whose C dependencies do not build for mach-o (aws-lc-sys) and anything linking Apple frameworks still fail — real macOS artifacts stay on Apple hardware for now. Signed-off-by: Simon Scatton <sscatton@nvidia.com>
1 parent d959896 commit d358a8c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎BUILD.bazel‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ platform(
1212
name = "linux_arm64_musl",
1313
parents = ["@zig_sdk//libc_aware/platform:linux_arm64_musl"],
1414
)
15+
16+
# Experimental: cross-compiling library crates to macOS. zig provides the
17+
# darwin libc headers and libSystem stubs; targets needing Apple framework
18+
# link stubs (Security, CoreFoundation) cannot link without an Apple SDK.
19+
platform(
20+
name = "darwin_arm64",
21+
parents = ["@zig_sdk//platform:darwin_arm64"],
22+
)

‎MODULE.bazel‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ rust.repository_set(
4646
],
4747
)
4848

49+
# Experimental macOS cross-compilation (library crates only; linking needs
50+
# Apple framework stubs that zig does not ship).
51+
rust.repository_set(
52+
name = "rust_darwin_arm64",
53+
exec_triple = "x86_64-unknown-linux-gnu",
54+
target_triple = "aarch64-apple-darwin",
55+
versions = ["1.95.0"],
56+
target_compatible_with = [
57+
"@platforms//os:macos",
58+
"@platforms//cpu:aarch64",
59+
],
60+
)
61+
4962
use_repo(rust, "rust_toolchains")
5063

5164
# The musl hub entries must be registered before //:all — the gnu entries in
@@ -76,6 +89,7 @@ use_repo(hermetic_toolchain, "zig_sdk")
7689
register_toolchains(
7790
"@zig_sdk//libc_aware/toolchain:linux_amd64_musl",
7891
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
92+
"@zig_sdk//toolchain:darwin_arm64",
7993
)
8094

8195
# Hermetic protoc for openshell-core's build script, injected via $PROTOC

0 commit comments

Comments
 (0)