Build clang-tidy with plugin support and publish plugin headers#13
Merged
Conversation
Workerd's JsgLint clang-tidy plugin needs the workerd-tools clang-tidy
binary to be built with LLVM_ENABLE_PLUGINS, CLANG_PLUGIN_SUPPORT and
LLVM_ENABLE_RTTI enabled so that plugins can be loaded via --load= and
resolve symbols against the running binary. Flip those three flags in
build/llvm/common.args.
Out-of-tree plugins also need a slice of the LLVM source / build tree
headers to compile against. Add a packaging step to the LLVM workflow
that, when the target contains 'clang-tidy', produces a per-platform
llvm-<version>-<os>-clang-tidy-dev.tar.xz asset containing:
- clang/include/{clang,clang-c}/**
- llvm/include/{llvm,llvm-c}/**
- build/include/** (generated config headers)
- build/tools/clang/include/** (generated clang config headers)
- clang-tools-extra/clang-tidy/**.h (plugin API)
The layout mirrors the LLVM source tree so consumers just need
-I clang/include -I llvm/include -I build/include
-I build/tools/clang/include -I clang-tools-extra. Generated headers
under build/ are platform-specific, hence one tarball per platform.
danlapid
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This enables workerd to ship its
JsgLintclang-tidy plugin against the workerd-tools-built clang-tidy binary.Two coordinated changes:
build/llvm/common.argsflipsLLVM_ENABLE_PLUGINS=ON,CLANG_PLUGIN_SUPPORT=ON, and addsLLVM_ENABLE_RTTI=ON. Without these the clang-tidy binary neither exports its symbols fordlopenresolution nor emits the typeinfo records that an out-of-tree plugin's vtable references, andclang-tidy --load=...fails.The LLVM workflow gains a packaging step that, when the requested target contains
clang-tidy, builds a per-platformllvm-<version>-<os>-clang-tidy-dev.tar.xzasset. It contains the headers needed to compile an out-of-tree plugin against this exact build:Layout mirrors the LLVM source tree, so a consumer just adds
-I clang/include -I llvm/include -I build/include -I build/tools/clang/include -I clang-tools-extra. Generated headers underbuild/are platform-specific, hence one tarball per matrix entry.The consuming workerd side (
build/tools/clang_tidy/plugin/BUILD.headers) already expects this layout; once a release is cut with this workflow change, the temporarynew_local_repositorypointing at a hand-built LLVM tree gets replaced with agithub_releaseentry inbuild/deps/build_deps.jsonc.Verified the workflow's packaging step locally by mirroring it against a hand-built LLVM 22 source/build tree and confirming that
bazel build //build/tools/clang_tidy/plugin:JsgLint.soin workerd consumes the resulting layout cleanly.