BAZEL_USE_CPP_ONLY_TOOLCHAIN doesn't work without Xcode / Xcode CLT installed.
uri-canva opened this issue · 0 comments
uri-canva commented
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
?
git@github.com: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?
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