Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAZEL_USE_CPP_ONLY_TOOLCHAIN doesn't work without Xcode / Xcode CLT installed. #134

Open
uri-canva opened this issue Jul 31, 2022 · 0 comments
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.

Comments

@uri-canva
Copy link

uri-canva commented Jul 31, 2022

Description of the bug:

Equivalent to Bazel issue: bazelbuild/bazel#16009

BAZEL_USE_CPP_ONLY_TOOLCHAIN on Darwin is meant to disable the Xcode toolchain resolution and use the common Unix toolchain resolution based on what binaries are available on the PATH and set with environment variables. However it will still hardcode several apple tools, like /usr/bin/libtool, /usr/bin/gcc and /usr/bin/install_name_tool (in cc_wrapper.sh).

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

# Either have an install of macOS without Xcode or Xcode CLT installed, or:
ln -s $(xcode-select -p) invalid
sudo xcode-select -s invalid
rm invalid

# try building a cc target with BAZEL_USE_CPP_ONLY_TOOLCHAIN having `libtool`, `install_name_tool` and `gcc` on your `PATH`:
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 bazel build //tools/cpp/runfiles

Expected output: successful build using the binaries on your PATH.
Actual output:

ERROR: /Users/uri/github/bazelbuild/bazel/tools/cpp/runfiles/BUILD:51:11: Compiling tools/cpp/runfiles/runfiles_src.cc failed: (Exit 1): cc_wrapper.sh failed: error executing command external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics ... (remaining 20 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
xcrun: error: active developer path ("/Users/uri/github/bazelbuild/bazel/invalid") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
Target //tools/cpp/runfiles:runfiles failed to build

Which operating system are you running Bazel on?

macOS 12.5 21G72

What is the output of bazel info release?

release 5.2.0

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

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

[email protected]:bazelbuild/bazel.git
c282526c071389cd6f88cb77565283b257316267
2e8458b7810eab7829fc7d28af5c45b9af91ed7c

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?

From: https://sourcegraph.com/github.com/tensorflow/runtime@021b5f0d3daea2d1666599d7d9c471a426c35f65/-/blob/third_party/rules_cuda/cuda/dependencies.bzl?L35-44

    http_archive(
        name = "rules_cc",
        sha256 = "ff7876d80cd3f6b8c7a064bd9aa42a78e02096544cca2b22a9cf390a4397a53e",
        strip_prefix = "rules_cc-081771d4a0e9d7d3aa0eed2ef389fa4700dfb23e",
        patches = [Label("//private:rules_cc.patch")],
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/081771d4a0e9d7d3aa0eed2ef389fa4700dfb23e.tar.gz",
            "https://github.com/bazelbuild/rules_cc/archive/081771d4a0e9d7d3aa0eed2ef389fa4700dfb23e.tar.gz",
        ],

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

See repro.

Have you found anything relevant by searching the web?

No response

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

No response

uri-canva added a commit to uri-canva/rules_cc that referenced this issue Jul 31, 2022
Instead of hardcoding `/usr/bin/libtool` which requires Xcode / Xcode CLT installed, which `BAZEL_USE_CPP_ONLY_TOOLCHAIN` is meant to avoid.

Related to bazelbuild#134.
@comius comius added the P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. label Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.
Projects
None yet
Development

No branches or pull requests

2 participants