[PATCH] D158942: [bazel] Include builtin headers with clang-tidy
Jordan Rupprecht via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 29 21:12:48 PDT 2023
rupprecht added a subscriber: alexfh.
rupprecht added a comment.
In D158942#4626240 <https://reviews.llvm.org/D158942#4626240>, @rnk wrote:
> + at rupprecht @aeubanks, can you review this Bazel change?
Sure, I can take a look, although I'm out at least the rest of the week. @alexfh, do you have any ideas here?
The root cause of the bug seems to be that clang-based tooling looks for headers relative to where it is, assuming it doesn't find it in `isystem` or similar flags. There are some brief docs that mention cmake-related things: https://clang.llvm.org/docs/LibTooling.html#builtin-includes. clang works because it's defined in the same build file as the clang builtin headers, and it has some transitive dep onto it, but that might actually be accidental.
I'm not sure the approach here makes sense, since it only fixes the case of using this tool directly from the blaze tree since now the directory will be placed in the right spot adjacent to clang-tidy. As soon as you copy the clang-tidy binary to install it somewhere, it will fail to find the headers if you don't also know that you have to copy that too.
But, I'm also not aware of any kind of well lit path for this kind of problem. The build file tree defines lots of targets to build and produce a bunch of build artifacts, but there isn't really an equivalent to running install targets that place all those build artifacts together and in the right configuration (e.g. clang needs to go next to clang headers). That's usually done by external means.
================
Comment at: utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel:19
+ srcs = ["//clang:builtin_headers_gen"],
+ destination = "lib/clang/{0}/include".format(LLVM_VERSION_MAJOR),
+ partition = BUILTIN_HEADERS_GEN_DIR,
----------------
Why does the symlink destination need the version in it?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158942/new/
https://reviews.llvm.org/D158942
More information about the llvm-commits
mailing list