From 6a716d69dedf4cbc4e4fa1159dfdf2399dcb6e51 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 11 Feb 2022 16:23:29 +0100 Subject: [PATCH] Emit correct darwin_x86_64 CPU value if not using Xcode Previously, if not using the Xcode toolchain, for example because the locator failed, the standard Unix C++ toolchain was created with a CPU value of either `darwin_arm64` or `darwin`, depending on the host architecture. The latter, when appended to `@local_config_cc//:cc-compiler-` in the toolchain BUILD template, results in a reference to a non-existent toolchain. --- tools/cpp/cc_configure.bzl | 2 +- tools/cpp/lib_cc_configure.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index 26155c8bab6971..a1051e24ad04ef 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -100,7 +100,7 @@ def cc_autoconf_impl(repository_ctx, overriden_tools = dict()): ]) repository_ctx.symlink(paths["@bazel_tools//tools/cpp:empty_cc_toolchain_config.bzl"], "cc_toolchain_config.bzl") repository_ctx.template("BUILD", paths["@bazel_tools//tools/cpp:BUILD.empty.tpl"], { - "%{cpu}": get_cpu_value(repository_ctx), + "%{cpu}": cpu_value, }) elif cpu_value == "freebsd" or cpu_value == "openbsd": paths = resolve_labels(repository_ctx, [ diff --git a/tools/cpp/lib_cc_configure.bzl b/tools/cpp/lib_cc_configure.bzl index f8689fb70b5048..964383f8a460cb 100644 --- a/tools/cpp/lib_cc_configure.bzl +++ b/tools/cpp/lib_cc_configure.bzl @@ -183,7 +183,7 @@ 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 "") + return "darwin" + ("_arm64" if arch == "aarch64" else "_x86_64") if os_name.find("freebsd") != -1: return "freebsd" if os_name.find("openbsd") != -1: