Skip to content

Commit

Permalink
Return "darwin" as cpu value on x86_64 for Bazel < 7
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv committed Nov 29, 2024
1 parent 0a4a932 commit 114aa7d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/private/get_cpu_value.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_skylib//lib:versions.bzl", "versions")

# see https://github.com/tweag/rules_nixpkgs/pull/613
# taken from https://github.com/bazelbuild/rules_cc/blob/8395ec0172270f3bf92cd7b06c9b5b3f1f679e88/cc/private/toolchain/lib_cc_configure.bzl#L225
Expand All @@ -13,7 +14,15 @@ def get_cpu_value(repository_ctx):
arch = repository_ctx.os.arch
if os_name.startswith("mac os"):
# Check if we are on x86_64 or arm64 and return the corresponding cpu value.
return "darwin_" + ("arm64" if arch == "aarch64" else "x86_64")
if arch == "aarch64":
return "darwin_arm64"

# NOTE(cb) for backward compatibility return "darwin" for Bazel < 7 on x86_64
if versions.is_at_least("7.0.0", versions.get):
return "darwin_x86_64"
else:
return "darwin"

if os_name.find("freebsd") != -1:
return "freebsd"
if os_name.find("openbsd") != -1:
Expand Down

0 comments on commit 114aa7d

Please sign in to comment.