[Lldb-commits] [PATCH] D26190: [RFC] Solve linking inconsistency, proposal two

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 1 07:05:01 PDT 2016


labath created this revision.
labath added reviewers: beanz, zturner, tfiala, clayborg, abidh.
labath added a subscriber: lldb-commits.
Herald added subscribers: mgorny, ki.stfu.

This "solves" the ODR violations by making the linker firewall a feature. llvm
libraries used by liblldb are considered to be private implementation details and
we do not provide them to the users. If some of them want to use llvm for their
private purposes, they should include their own copy. LLDB_EXPORT_ALL_SYMBOLS=OFF
is the official way of building liblldb, and the =ON version is a hack to make
backtrace(3) output more useful on linux. It still should not affect the way
dependant executables are linked, as none of them should be using lldb_private
symbols in the first place.

We need to be careful to not use llvm classes anywhere along the API boundary, or
bad things will happen. With our current SB API policy this should not be a
problem, but we may need to revisit this decision if that changes.

This is my less preferred solution, as it increases code size, and has potential
to introduce latent bugs.


https://reviews.llvm.org/D26190

Files:
  tools/lldb-mi/CMakeLists.txt


Index: tools/lldb-mi/CMakeLists.txt
===================================================================
--- tools/lldb-mi/CMakeLists.txt
+++ tools/lldb-mi/CMakeLists.txt
@@ -1,5 +1,3 @@
-include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
-
 set(LLDB_MI_SOURCES
   MICmdArgContext.cpp
   MICmdArgSet.cpp
@@ -83,15 +81,18 @@
     )
 endif ()
 
+# liblldb already contains a copy of the llvm support library. However, it is not
+# a part of the interface provided by liblldb, so we need to include our own
+# copy.  We need to be careful to never pass llvm objects across SO boundary.
+# This should be fine, as lldb SB API does not (by design) depend on llvm.
+set(LLVM_LINK_COMPONENTS Support)
 add_lldb_executable(lldb-mi ${LLDB_MI_SOURCES})
 
 target_link_libraries(lldb-mi liblldb)
 if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
   target_link_libraries(lldb-mi pthread)
 endif ()
 
-llvm_config(lldb-mi ${LLVM_LINK_COMPONENTS})
-
 set_target_properties(lldb-mi PROPERTIES VERSION ${LLDB_VERSION})
 
 install(TARGETS lldb-mi


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26190.76554.patch
Type: text/x-patch
Size: 1036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161101/ebf912d1/attachment.bin>


More information about the lldb-commits mailing list