Skip to content

Commit 6d673bc

Browse files
committed
[cmake] lldb: Build libraries with -DCLANG_BUILD_STATIC on Windows
By default (`CLANG_BUILD_STATIC` and `CLANG_EXPORTS` not defined) some Clang visibility macros expand to `__declspec(dllimport)`. LLDB depends on Clang statically, so needs to turn these macros off. See: https://github.com/llvm/llvm-project/pull/108276/files#diff-4dd645a8b76bb3886a505258a8c2e598aeddea770e7b0a2b51689124a5ea6e9a.
1 parent eba03c4 commit 6d673bc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lldb/cmake/modules/AddLLDB.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ function(add_lldb_library name)
9292
${pass_NO_INSTALL_RPATH}
9393
)
9494

95+
if(MSVC)
96+
# LLDB libraries are always linked with Clang libraries statically, so turn
97+
# off Clang visibility macros for both the library and its consumers.
98+
target_compile_definitions(${name} PUBLIC CLANG_BUILD_STATIC)
99+
if(TARGET "obj.${name}")
100+
target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC)
101+
endif()
102+
endif()
103+
95104
if(CLANG_LINK_CLANG_DYLIB)
96105
target_link_libraries(${name} PRIVATE clang-cpp)
97106
else()

0 commit comments

Comments
 (0)