From 47658d3219fae1d73ef6b48546a8a130ccb351f7 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 29 Nov 2024 10:54:02 +0100 Subject: [PATCH] Return "darwin" as cpu value on x86_64 for Bazel < 7 --- core/private/get_cpu_value.bzl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/private/get_cpu_value.bzl b/core/private/get_cpu_value.bzl index 49b840ea..1fba17f7 100644 --- a/core/private/get_cpu_value.bzl +++ b/core/private/get_cpu_value.bzl @@ -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 @@ -12,8 +13,16 @@ def get_cpu_value(repository_ctx): os_name = repository_ctx.os.name arch = repository_ctx.os.arch if os_name.startswith("mac os"): + if arch == "aarch64": + return "darwin_arm64" + # Check if we are on x86_64 or arm64 and return the corresponding cpu value. - return "darwin_" + ("arm64" if arch == "aarch64" else "x86_64") + # 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: