Page MenuHomePhabricator

[lldb] Enable building with Cmake/BUILD_SHARED_LIBS
ClosedPublic

Authored by axw on Jun 1 2015, 1:11 AM.

Details

Summary

Several changes to fix CMake builds of LLDB with the
BUILD_SHARED_LIBS setting on.

  • Force all internal libraries to be built STATIC.
  • Add additional library dependencies (pthread, dl, runtimedyld).
  • modify finalisation of SWIG wrapper to symlink the "lib" dir into python/site-packages, so _lldb.so's RPATH resolves.

Diff Detail

Event Timeline

axw updated this revision to Diff 26879.Jun 1 2015, 1:11 AM
axw retitled this revision from to [lldb] Enable building with Cmake/BUILD_SHARED_LIBS.
axw updated this object.
axw edited the test plan for this revision. (Show Details)
axw added a reviewer: sylvestre.ledru.
axw added a subscriber: Unknown Object (MLST).

Would it be easier instead of modifying every CMakeLists.txt file -- which has the con of requiring every person to remember to make future CMakeLists.txt files include this keyword as well -- to just kill support for BUILD_SHARED_LIBS at the CMake level, and have static be the default?

In other words, change add_lldb_library to just force static.

BUILD_SHARED_LIBS is completely broken in LLDB, and as you pointed out on the email thread, there is no way to make it work due to the circular dependencies that are pervasive throughout the codebase. So I think we should just remove it.

axw added a comment.Jun 1 2015, 6:07 PM

Would it be easier instead of modifying every CMakeLists.txt file -- which has the con of requiring every person to remember to make future CMakeLists.txt files include this keyword as well -- to just kill support for BUILD_SHARED_LIBS at the CMake level, and have static be the default?

In other words, change add_lldb_library to just force static.

BUILD_SHARED_LIBS is completely broken in LLDB, and as you pointed out on the email thread, there is no way to make it work due to the circular dependencies that are pervasive throughout the codebase. So I think we should just remove it.

Certainly easier and less error-prone; I wasn't sure if precluding either/or static/shared would be acceptable. I'll change it to do that.

axw updated this revision to Diff 26945.Jun 1 2015, 6:30 PM

Default add_lldb_library to STATIC

I tried your patch but it does not generate libLLVM-3.7.so like autotool is. Is that expected?

axw added a comment.Jun 2 2015, 12:41 AM

I tried your patch but it does not generate libLLVM-3.7.so like autotool is. Is that expected?

This patch is only addressing issues with building LLDB.

There are some other differences between autotools and CMake builds, but this patch doesn't address them. There is lib/libLLVM.so.3.7, but no lib/libLLVM-3.7.so. In the CMake build, tools such as lldb link against the individual component shared libraries anyway:

$ ldd bin/lldb
linux-vdso.so.1 =>  (0x00007ffd203f5000)
liblldb.so.3.7 => /home/andrew/code/src/llvm.org/build/bin/../lib/liblldb.so.3.7 (0x00007fb8badcf000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb8baa9e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb8ba6d3000)
libLLVMX86CodeGen.so.3.7 => /home/andrew/code/src/llvm.org/build/bin/../lib/../lib/libLLVMX86CodeGen.so.3.7 (0x00007fb8ba146000)
libLLVMX86Desc.so.3.7 => /home/andrew/code/src/llvm.org/build/bin/../lib/../lib/libLLVMX86Desc.so.3.7 (0x00007fb8b9d8e000)
libLLVMX86Info.so.3.7 => /home/andrew/code/src/llvm.org/build/bin/../lib/../lib/libLLVMX86Info.so.3.7 (0x00007fb8b9b8b000)
(etc...)

(I'm not sure if this is desirable, but it's just how things are currently.)

zturner added inline comments.Jun 2 2015, 11:58 AM
scripts/Python/finishSwigPythonLLDB.py
307–308

I'm having some trouble visualizing what this is doing. What do a sample strSrc and strTarget look like before and after this change? (i.e. what was broken that this is fixing?)

376–380

I think this shouldn't be done on Windows. Windows doesn't have a notion of RPATH or LD_LIBRARY_PATH.

tools/lldb-server/CMakeLists.txt
32–34

Should this be

if (HAVE_LIBPTHREAD)

?

axw updated this revision to Diff 27024.Jun 2 2015, 9:59 PM
axw edited edge metadata.
  • HAVE_LIBPTHREAD instead of Windows check
  • Don't create lib symlink on Windows
scripts/Python/finishSwigPythonLLDB.py
307–308

Without this change, the "lib" symlink looks like this:

$ readlink lib/python2.7/site-packages/lib
../../../../lib

which is one too many ".."s. The problem is that the symlinks are being created relative to site-packages/lldb, rather than where the symlink is located. It just happened that all the symlinks were in site-packages/lldb before.

This change makes the source relative to the target, since that's how the symlink will be followed.

376–380

Fixed.

tools/lldb-server/CMakeLists.txt
32–34

Done.

axw added a comment.Jun 3 2015, 3:28 AM

Lgtm

Thanks! Are you able to accept the revision so I can commit?

zturner accepted this revision.Jun 3 2015, 9:52 AM
zturner added a reviewer: zturner.
This revision is now accepted and ready to land.Jun 3 2015, 9:52 AM
axw closed this revision.Jun 3 2015, 8:16 PM