[PATCH] D145258: [bazel] Don't alwayslink clang-tidy libraries

Aaron Siddhartha Mondal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 3 14:49:57 PST 2023


aaronmondal added a comment.

In D145258#4168143 <https://reviews.llvm.org/D145258#4168143>, @dblaikie wrote:

> I would've thought it was necessary to alwayslink them because maybe they use some kind of auto-registration system into clang-tidy, so without alwayslink your clang-tidy binary wouldn't link any of them in?

I think the reason `alwayslink` was in here was because https://reviews.llvm.org/D143804 also took https://github.com/eomii/rules_ll/commit/678b1e4698aca2c8d5767c95e5245e60921754e into consideration, which originally copied the general structure from https://github.com/llvm/llvm-project/blob/main/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl.

As far as I can remember this was just an oversight in the original implementation. I wasn't aware of the implications of `alwayslink` until @GMNGeoffrey mentioned it in https://reviews.llvm.org/D143804. But the clang-tidy "modules" don't seem to work like plugins and a Bazel-built clang-tidy executable seems to work fine without this flag.

> But I could be wrong, maybe they're explicitly referenced in the clang-tidy binary?

I think this is what the ClangTidyForceLinker.h <https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h> file (also included by `ClangTidyMain.cpp`) does.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145258/new/

https://reviews.llvm.org/D145258



More information about the llvm-commits mailing list