[clang-tools-extra] [clangd] Add dynamic plugins support (PR #226995)
Aleksandr Platonov via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 04:02:52 PDT 2026
================
@@ -30,6 +30,36 @@ foreach(dep FileCheck count not llvm-config)
endif()
endforeach()
+if (NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB)
+ llvm_add_library(
+ ClangdFeatureModuleExample
+ MODULE FeatureModuleExample.cpp
+ PLUGIN_TOOL clangd
+ PARTIAL_SOURCES_INTENDED)
+ llvm_add_library(
+ ClangdStandaloneTweakExample
+ MODULE StandaloneTweakExample.cpp
+ PLUGIN_TOOL clangd
+ PARTIAL_SOURCES_INTENDED)
+endif()
+
+foreach(target ClangdFeatureModuleExample ClangdStandaloneTweakExample)
+ if(TARGET ${target})
+ list(APPEND CLANGD_TEST_DEPS ${target})
+ target_include_directories(${target} PUBLIC BEFORE
+ "${CLANG_TOOLS_SOURCE_DIR}/clangd"
+ "${CMAKE_CURRENT_BINARY_DIR}/.."
+ )
+ if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+ set(LLVM_LINK_COMPONENTS
+ Support
+ )
+ endif()
+ endif()
+endforeach()
+
+llvm_canonicalize_cmake_booleans(CLANG_PLUGIN_SUPPORT)
----------------
ArcsinX wrote:
I expect that we won't support clang plugins inside clangd (and we explicitly drop clang plugins options from compilation commands as I clarified in previous commen). As I mention in the description, the aim is to support clangd-specific plugins (FeatureModules, Tweaks) and clang-tidy (as a side effect, but also useful).
`CLANG_PLUGIN_SUPPORT` here is just an indicator that we want to build clang tools with plugins support enabled (by meaning export symbols to open ability of plugins loading). I didn't introduce new `CLANGD_PLUGIN_SUPPORT` ([clang-tidy](https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/tool/CMakeLists.txt#L35) also doesn't do this) because it maybe not very obvious what to do if `CLANG_PLUGIN_SUPPORT` is disabled but `CLANGD_PLUGIN_SUPPORT` is enabled.
https://github.com/llvm/llvm-project/pull/226995
More information about the cfe-commits
mailing list