This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.
ClosedPublic

Authored by wallace on Apr 3 2023, 10:02 AM.

Details

Summary

If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we need to use default visibility for all LLDB libraries even if a global CMAKE_CXX_VISIBILITY_PRESET=hidden is present. In fact, there are cases in which a global llvm configuration wants CMAKE_CXX_VISIBILITY_PRESET as hidden but simultaneously LLDB_EXPORT_ALL_SYMBOLS=ON is also needed to be able to develop out-of-tree lldb plugins.

Diff Detail

Event Timeline

wallace created this revision.Apr 3 2023, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2023, 10:02 AM
wallace requested review of this revision.Apr 3 2023, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2023, 10:02 AM
wallace edited the summary of this revision. (Show Details)Apr 3 2023, 10:04 AM
wallace added reviewers: labath, clayborg.
wallace updated this revision to Diff 510551.Apr 3 2023, 10:41 AM

another nit...

wallace edited the summary of this revision. (Show Details)Apr 3 2023, 10:41 AM
rriddle added inline comments.Apr 3 2023, 10:50 AM
lldb/cmake/modules/AddLLDB.cmake
173

Other places uses if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") to check for non-windows, should that check be used here as well? Not sure what's consistent for the lldb codebase.

wallace added inline comments.Apr 3 2023, 10:53 AM
lldb/cmake/modules/AddLLDB.cmake
173

I initially thought that it might be fine just to check the compiler id, but better be safer gating the target OS as well.

wallace updated this revision to Diff 510557.Apr 3 2023, 10:54 AM

gate the target OS

rriddle accepted this revision.Apr 3 2023, 11:00 AM

LGTM, and makes sense to me given that downstream users often want a build of LLVM with CMAKE_CXX_VISIBILITY_PRESET=hidden, but lldb should still be able to build/link/work in the presence of that (the LLDB driver and tools currently fail to link if LLVM is built CMAKE_CXX_VISIBILITY_PRESET=hidden).

This revision is now accepted and ready to land.Apr 3 2023, 11:00 AM
JDevlieghere added inline comments.Apr 3 2023, 1:23 PM
lldb/cmake/modules/AddLLDB.cmake
175

Rather than changing the compile options directly, can we change the CXX_VISIBILITY_PRESET property?

set_target_properties((${name} PROPERTIES CXX_VISIBILITY_PRESET default)
wallace added inline comments.Apr 3 2023, 1:36 PM
lldb/cmake/modules/AddLLDB.cmake
175

Thanks @JDevlieghere , that works and is cleaner

wallace updated this revision to Diff 510588.Apr 3 2023, 1:37 PM

Address comments

JDevlieghere accepted this revision.Apr 3 2023, 1:37 PM

Thanks! LGTM