Skip to content

[stable/21.x][cmake] lldb: Turn of clang visibility macros if not CLANG_LINK_CLANG_DYLIB #11127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: stable/21.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lldb/cmake/modules/AddLLDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ function(add_lldb_library name)
${pass_NO_INSTALL_RPATH}
)

if(MSVC AND NOT CLANG_LINK_CLANG_DYLIB)
# Make sure all consumers also turn off visibility macros so the're not
# trying to dllimport symbols.
target_compile_definitions(${name} PUBLIC CLANG_BUILD_STATIC)
if(TARGET "obj.${name}")
target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC)
endif()
elseif(NOT PARAM_SHARED AND NOT PARAM_STATIC)
# lldb component libraries linked in to clang-cpp are declared without
# SHARED or STATIC.
target_compile_definitions("obj.${name}" PUBLIC CLANG_EXPORTS)
endif()

if(CLANG_LINK_CLANG_DYLIB)
target_link_libraries(${name} PRIVATE clang-cpp)
Comment on lines +95 to 109
Copy link
Author

@AnthonyLatsis AnthonyLatsis Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This

if(MSVC AND NOT CLANG_LINK_CLANG_DYLIB)
  ...
elseif(NOT PARAM_SHARED AND NOT PARAM_STATIC)
  target_compile_definitions("obj.${name}" PUBLIC CLANG_EXPORTS)
endif()

...

if(CLANG_LINK_CLANG_DYLIB)
  target_link_libraries(${name} PRIVATE clang-cpp)

flow is odd.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @fsfod

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk why i did it that way, but do the LLDB libraries even need there API exported from the clang shared library anyway? I should also mention @andrurogerz is continuing most of the work on this now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is something off with the way the CLANG_ABI annotation definitions are gated right now in LLVM main. I found yesterday that after annotating a bunch of the clang symbols the project doesn't build on Windows even when you don't enable DLL builds. I have not looked into the issue.

else()
Expand Down