[clang-tools-extra] [clangd] Clear LLVM_LINK_COMPONENTS for test plugin modules (PR #230359)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 22:45:57 PDT 2026


https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/230359

clang-tools-extra/clangd/CMakeLists.txt sets directory-scoped
LLVM_LINK_COMPONENTS (including Support), which is inherited by
clang-tools-extra/clangd/test/plugins/CMakeLists.txt.

When building ClangdFeatureModuleExample and
ClangdStandaloneTweakExample (added in #226995), llvm_add_library
statically links libLLVMSupport.a into the plugin shared libraries
unless LLVM_LINK_COMPONENTS is cleared before creating the targets.
Loading these plugins into clangd then triggers an ASan ODR violation on
llvm::vfs::FileSystem::ID because both clangd and the plugin module
contain their own copy of VirtualFileSystem.cpp.o.

Clear LLVM_LINK_COMPONENTS before calling llvm_add_library so the
plugins resolve LLVM symbols from the clangd executable at load time,
and remove the dead post-target LLVM_LINK_COMPONENTS block.

Assisted-by: Gemini


>From 223d657d2d852d94237730a65d48cef2cadfc061 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Thu, 8 Oct 2026 22:45:34 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 clang-tools-extra/clangd/test/plugins/CMakeLists.txt | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/clangd/test/plugins/CMakeLists.txt b/clang-tools-extra/clangd/test/plugins/CMakeLists.txt
index 5097e50dbffc5..7b144ab0d88d3 100644
--- a/clang-tools-extra/clangd/test/plugins/CMakeLists.txt
+++ b/clang-tools-extra/clangd/test/plugins/CMakeLists.txt
@@ -1,3 +1,5 @@
+set(LLVM_LINK_COMPONENTS)
+
 if (NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB)
   llvm_add_library(
       ClangdFeatureModuleExample
@@ -18,11 +20,6 @@ foreach(target ClangdFeatureModuleExample ClangdStandaloneTweakExample)
       "${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()
 



More information about the cfe-commits mailing list