rules_cc icon indicating copy to clipboard operation
rules_cc copied to clipboard

configure_unix_toolchain: Allow overriding path to libtool on macOS

Open veprbl opened this issue 2 years ago • 1 comments

Description of the problem / feature request:

The path to the archive manipulation tool is hardcoded on macOS https://github.com/bazelbuild/rules_cc/blob/081771d4a0e9d7d3aa0eed2ef389fa4700dfb23e/cc/private/toolchain/unix_cc_configure.bzl#L375 It would be nice to have a mechanizm to override this value externally, for example by adding a AR/BAZEL_AR environment variable.

Feature requests: what underlying problem are you trying to solve with this feature?

In nixpkgs we build our own toolchain for macOS from open source components. The static library builds rely on ar, and rules_cc hardcode it to be called at /usr/bin/libtool, which does not belong to our toolchain. Our builds are supposed to not rely on Apple SDK, and, in fact, it need not be even installed. We would like to supply our working version of libtool, the same way we specify CC, but apparently there isn't a way to do so.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 3.7.2- (@non-git)

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?

Same as tensorflow 2.7.0: 01d4a48911d5e7591ecb1c06d3b8af47fe872371

What Bazel options do you use to trigger the issue? What C++ toolchain do you use?

The toolchain is "stdenv" for x86_64-darwin from nixpkgs based on:

clang version 7.1.0 (tags/RELEASE_710/final)

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

ERROR: /private/tmp/nix-build-tensorflow-2.7.0.drv-0/output/external/com_google_protobuf/BUILD:301:11: Linking of rule '@com_google_protobuf//:protoc_lib' failed (Exit 1): libtool failed: error executing command /usr/bin/libtool -static -s -o bazel-out/host/bin/external/com_google_protobuf/libprotoc_lib.a bazel-out/host/bin/external/com_google_protobuf/_objs/protoc_lib/code_generator.o ... (remaining 80 argument(s) skipped)

veprbl avatar Nov 21 '21 01:11 veprbl

Related: https://github.com/bazelbuild/rules_cc/issues/134

uri-canva avatar Jul 31 '22 07:07 uri-canva