Page MenuHomePhabricator

[cmake] Explicitly link dependency libraries in the Host library

Authored by mgorny on Aug 18 2017, 11:15 AM.



Add explicit linkage to the necessary system libraries in the Host
library. Otherwise, the library fails to build with -Wl,--as-needed.
The system libraries ended up being listed on the linker command-line
before the static libraries needing them, resulting in --as-needed
stripping them.

Listing the dependent libraries explicitly is the canonical way of
declaring libraries in CMake. It guarantees that the system library
dependencies will be correctly propagated to reverse dependencies.

The code used to link libraries reuses existing EXTRA_LIBS variable,
copying code from other parts of LLDB. We might eventually remove
the direct use of system libraries in the programs; however, I would
prefer if we focused on fixing the build regressions in 5.0 branch
first, and went further after the release.

Diff Detail


Event Timeline

mgorny created this revision.Aug 18 2017, 11:15 AM
zturner added inline comments.Aug 18 2017, 4:25 PM
166–168 ↗(On Diff #111708)

Even if libxml is found, that doesn't mean the build is configured to use it, does it? Correct me if I'm wrong. if "libxml exists" is the same as "i want to use libxml" then this seems fine.

mgorny added inline comments.Aug 19 2017, 12:08 AM
166–168 ↗(On Diff #111708)

Strictly speaking, it's not the same. However, LLDB build system does not provide an explicit option to disable building with libxml2 support, so it's not a regression. It's exactly the same logic as used in other parts of LLDB. If you want, I can look into adding an additional conditional for it in a followup patch. However, I'm not sure if it should be applied to APPLE as well or not since the presumption of libxml2 is unconditional there right now.

zturner accepted this revision.Aug 21 2017, 10:25 AM
This revision is now accepted and ready to land.Aug 21 2017, 10:25 AM
This revision was automatically updated to reflect the committed changes.