Closed davidzchen closed 4 days ago
This is a common issue for os-provided llvm installs, particularly when you're using an older macos system install (from "/Users" I assume this is macos). See contribution tools for advice on installing llvm.
If that doesn't address your issue, please provide the output of these troubleshooting commands:
echo $CC
which clang
which clang-16
clang --version
grep llvm_bindir $(bazel info workspace)/bazel-execroot/external/bazel_cc_toolchain/clang_detected_variables.bzl
# If on macOS:
brew --prefix llvm
I think I know what went wrong here; there needs to be a semi-colon for the end of line 364 or 367, I'm not sure. Let me know how this solution goes.
In that case, delete every single goddamn semicolon from this goddamn file. See if that works.
Cool. #Mark issue as resolved
Sorry if I seem crazy, but I'm not sure what's going on for this issue.
I'm on a MacBook btw.
You just need to run npm update or something like that. Please mark this issue as resolved.
Am I wrong?
@justzh - Please keep comments on PRs and issues constructive and on-topic. I'm hiding yours, but you've had warnings now and so I will block if this continues.
Rapid-fire asking of questions, or speaking for the reporter isn't a constructive or appropriate use of issues.
I found the issue. Please look at line 32 and correct your code, thanks.
Sorry for the delay. I followed the instructions at Contribution Tools but I am still getting the same error:
$ brew install \
bazelisk \
gh \
llvm \
python@3.10 \
pre-commit
---snipped---
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ bazel test //...:all
2024/04/07 15:34:48 Downloading https://releases.bazel.build/7.1.0/release/bazel-7.1.0-darwin-arm64...
Downloading: 61 MB out of 61 MB (100%)
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
WARNING: ignoring JAVA_TOOL_OPTIONS in environment.
INFO: Invocation ID: 9f0eb370-661d-495e-8e64-61ba0554c834
INFO: Repository _main~clang_toolchain_extension~bazel_cc_toolchain instantiated at:
<builtin>: in <toplevel>
Repository rule configure_clang_toolchain defined at:
/Users/dzc/Repos/github/carbon-language/carbon-lang/bazel/cc_toolchains/clang_configuration.bzl:229:44: in <toplevel>
ERROR: An error occurred during the fetch of repository '_main~clang_toolchain_extension~bazel_cc_toolchain':
Traceback (most recent call last):
File "/Users/dzc/Repos/github/carbon-language/carbon-lang/bazel/cc_toolchains/clang_configuration.bzl", line 202, column 17, in _configure_clang_toolchain_impl
fail("`llvm-ar` not found in PATH or adjacent to clang")
Error in fail: `llvm-ar` not found in PATH or adjacent to clang
ERROR: <builtin>: fetching configure_clang_toolchain rule //:_main~clang_toolchain_extension~bazel_cc_toolchain: Traceback (most recent call last):
File "/Users/dzc/Repos/github/carbon-language/carbon-lang/bazel/cc_toolchains/clang_configuration.bzl", line 202, column 17, in _configure_clang_toolchain_impl
fail("`llvm-ar` not found in PATH or adjacent to clang")
Error in fail: `llvm-ar` not found in PATH or adjacent to clang
ERROR: Skipping '//...:all': error loading package under directory '': no such package '@@_main~clang_toolchain_extension~bazel_cc_toolchain//': `llvm-ar` not found in PATH or adjacent to clang
ERROR: error loading package under directory '': no such package '@@_main~clang_toolchain_extension~bazel_cc_toolchain//': `llvm-ar` not found in PATH or adjacent to clang
INFO: Elapsed time: 2.995s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Couldn't start the build. Unable to run tests
Outputs for the requested commands:
$ which $CC
# no output
$ which clang
/usr/bin/clang
$ which clang-16
clang-16 not found
$ clang --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ grep llvm_bindir $(bazel info workspace)/bazel-execroot/external/bazel_cc_toolchain/clang_detected_variables.bzl
INFO: Invocation ID: ce012800-43b0-4d82-b9f5-9ddb32bfb8fe
grep: /Users/dzc/Repos/github/carbon-language/carbon-lang/bazel-execroot/external/bazel_cc_toolchain/clang_detected_variables.bzl: No such file or directory
$ brew --prefix llvm
/opt/homebrew/opt/llvm
$ which clang /usr/bin/clang
It looks like you need to add brew's llvm to your path, as described at https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md#macos:
# For `brew`, `gh`, and other tools:
export PATH="${HOME}/.brew/bin:${PATH}"
# For `llvm`:
export PATH="$(brew --prefix llvm)/bin:${PATH}"
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive
label. The long term
label can also be added for issues which are expected to take time.
This issue is labeled inactive
because the last activity was over 90 days ago.
Closing, please let us know if the PATH
fixes don't address this for you.
Description of the bug:
Building Carbon with the clang-tidy configuration results in an error reporting that "
llvm-ar
not found in PATH or adjacent to clang"What did you do, or what's a simple way to reproduce the bug?
Fresh check-out of the repo and then run:
What did you expect to happen?
The build to succeed.
What actually happened?
Any other information, logs, or outputs that you want to share?
No response