From 17ac479c1033f1c9dcb370ba839dbc035086cbdd Mon Sep 17 00:00:00 2001 From: kshyanashree <109167932+kshyanashree@users.noreply.github.com> Date: Fri, 27 Jan 2023 09:58:29 -0800 Subject: [PATCH] Find `libtool` when using `BAZEL_USE_CPP_ONLY_TOOLCHAIN`. (#17327) Instead of hardcoding `/usr/bin/libtool` which requires Xcode / Xcode CLT installed, which `BAZEL_USE_CPP_ONLY_TOOLCHAIN` is meant to avoid. Related to https://github.com/bazelbuild/bazel/issues/16009. Closes #16010. PiperOrigin-RevId: 503922158 Change-Id: I64392ada951938d612dd0b28141e6b2e4ee6952c Co-authored-by: Uri Baghin --- tools/cpp/cc_configure.bzl | 1 + tools/cpp/unix_cc_configure.bzl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index 6d0bca10dab559..9dd40dc10862da 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -169,6 +169,7 @@ cc_autoconf = repository_rule( "CPLUS_INCLUDE_PATH", "DEVELOPER_DIR", "GCOV", + "LIBTOOL", "HOMEBREW_RUBY_PATH", "SYSTEMROOT", "USER", diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index bfb37bddb4c203..9e19954c604fb7 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -384,7 +384,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): ) if darwin: overriden_tools["gcc"] = "cc_wrapper.sh" - overriden_tools["ar"] = "/usr/bin/libtool" + overriden_tools["ar"] = _find_generic(repository_ctx, "libtool", "LIBTOOL", overriden_tools) auto_configure_warning_maybe(repository_ctx, "CC used: " + str(cc)) tool_paths = _get_tool_paths(repository_ctx, overriden_tools) cc_toolchain_identifier = escape_string(get_env_var(