llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tools-extra

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/230359.diff


1 Files Affected:

- (modified) clang-tools-extra/clangd/test/plugins/CMakeLists.txt (+2-5) 


``````````diff
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()
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/230359
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to