-
Notifications
You must be signed in to change notification settings - Fork 344
[cmake] lldb: Build libraries with -DCLANG_BUILD_STATIC
on Windows
#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
base: stable/21.x
Are you sure you want to change the base?
Conversation
lldb/cmake/modules/AddLLDB.cmake
Outdated
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @fsfod
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
8ae4466
to
6d673bc
Compare
CLANG_LINK_CLANG_DYLIB
-DCLANG_BUILD_STATIC
on Windows
By default (
CLANG_BUILD_STATIC
andCLANG_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.