[clang] [clang-tools-extra] [clangd] Update clangDaemonTweaks to set symbol visibility macros (PR #112304)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 20:50:03 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Thomas Fransham (fsfod)

<details>
<summary>Changes</summary>

Update clangDaemonTweaks cmake target to set explicit symbol visibility macros to correct mode for windows.
This will fix linker duplicate symbols errors from clangDaemonTweaks exporting clang symbols instead of importing them for windows shared library builds using explicit symbol visibly.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM/Clang plugins on window.

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


2 Files Affected:

- (modified) clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt (+1-1) 
- (modified) clang/cmake/modules/AddClang.cmake (+2-2) 


``````````diff
diff --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 59475b0dfd3d22..fa4ccba52e8831 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -11,7 +11,7 @@ set(LLVM_LINK_COMPONENTS
 # To enable these tweaks in executables or shared libraries, add
 # $<TARGET_OBJECTS:obj.clangDaemonTweaks> to a list of sources, see
 # clangd/tool/CMakeLists.txt for an example.
-add_clang_library(clangDaemonTweaks OBJECT
+add_clang_library(clangDaemonTweaks CLANG_IMPORT OBJECT
   AddUsing.cpp
   AnnotateHighlightings.cpp
   DumpAST.cpp
diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index 091aec98e93ca3..33f47190afa26e 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -47,7 +47,7 @@ endmacro()
 
 macro(add_clang_library name)
   cmake_parse_arguments(ARG
-    "SHARED;STATIC;INSTALL_WITH_TOOLCHAIN"
+    "SHARED;STATIC;INSTALL_WITH_TOOLCHAIN;CLANG_IMPORT"
     ""
     "ADDITIONAL_HEADERS"
     ${ARGN})
@@ -114,7 +114,7 @@ macro(add_clang_library name)
     if(TARGET "obj.${name}")
       target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC)
     endif()
-  elseif(NOT ARG_SHARED AND NOT ARG_STATIC)
+  elseif(NOT ARG_SHARED AND NOT ARG_STATIC AND NOT ARG_CLANG_IMPORT)
     # Clang component libraries linked in to clang-cpp are declared without SHARED or STATIC
     target_compile_definitions("obj.${name}" PUBLIC CLANG_EXPORTS)
   endif()

``````````

</details>


https://github.com/llvm/llvm-project/pull/112304


More information about the cfe-commits mailing list