Skip to content

Commit

Permalink
Emit correct darwin_x86_64 CPU value if not using Xcode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fmeum committed Feb 11, 2022
1 parent 8431ef3 commit 6a716d6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/cpp/cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/lib_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6a716d6

Please sign in to comment.