Skip to content

Commit

Permalink
Fix unix toolchain for macos arm64 platform
Browse files Browse the repository at this point in the history
This allow the basic unix toolchain to work on Apple silicon without
Xcode installed.

Fixes bazelbuild#13514

Closes bazelbuild#13515.

PiperOrigin-RevId: 375711139
  • Loading branch information
meteorcloudy authored and copybara-github committed May 25, 2021
1 parent b018ea1 commit b4b0c32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/cpp/cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def cc_autoconf_impl(repository_ctx, overriden_tools = dict()):
configure_windows_toolchain(repository_ctx)
elif (cpu_value.startswith("darwin") and
("BAZEL_USE_CPP_ONLY_TOOLCHAIN" not in env or env["BAZEL_USE_CPP_ONLY_TOOLCHAIN"] != "1")):
configure_osx_toolchain(repository_ctx, overriden_tools)
configure_osx_toolchain(repository_ctx, cpu_value, overriden_tools)
else:
configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools)

Expand Down
4 changes: 2 additions & 2 deletions tools/cpp/osx_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _compile_cc_file(repository_ctx, src_name, out_name):
"https://github.com/bazelbuild/bazel/issues with the following:\n" +
error_msg)

def configure_osx_toolchain(repository_ctx, overriden_tools):
def configure_osx_toolchain(repository_ctx, cpu_value, overriden_tools):
"""Configure C++ toolchain on macOS.
Args:
Expand Down Expand Up @@ -187,4 +187,4 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
},
)
else:
configure_unix_toolchain(repository_ctx, cpu_value = "darwin", overriden_tools = overriden_tools)
configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools = overriden_tools)
2 changes: 1 addition & 1 deletion tools/cpp/unix_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
)

repository_ctx.file("tools/cpp/empty.cc", "int main() {}")
darwin = cpu_value == "darwin"
darwin = cpu_value.startswith("darwin")

cc = _find_generic(repository_ctx, "gcc", "CC", overriden_tools)
is_clang = _is_clang(repository_ctx, cc)
Expand Down

0 comments on commit b4b0c32

Please sign in to comment.