This is an archive of the discontinued LLVM Phabricator instance.

[lldb][gdb-remote] Fix linking of gdb-remote when LLVM_ENABLE_ZLIB is ON
ClosedPublic

Authored by mceier on Feb 7 2022, 1:42 PM.

Details

Summary

When LLVM_ENABLE_ZLIB is ON gdb-remote should link with ZLIB::ZLIB.

Fixes https://reviews.llvm.org/D119058#3301524

Diff Detail

Event Timeline

mceier created this revision.Feb 7 2022, 1:42 PM
mceier requested review of this revision.Feb 7 2022, 1:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 1:42 PM
JDevlieghere requested changes to this revision.EditedFeb 7 2022, 1:49 PM

We should add this to LLDB_SYSTEM_LIBS like we do in lldb/source/Host/CMakeLists.txt and include ${LLDB_SYSTEM_LIBS} for lldbPluginProcessGDBRemote.

This revision now requires changes to proceed.Feb 7 2022, 1:49 PM

Basically it should mirror what we have for LZMA:

if (LLDB_ENABLE_LZMA)
  list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
endif()
mceier added a comment.Feb 7 2022, 2:42 PM

We should add this to LLDB_SYSTEM_LIBS like we do in lldb/source/Host/CMakeLists.txt and include ${LLDB_SYSTEM_LIBS} for lldbPluginProcessGDBRemote.

So should I add:

if(LLVM_ENABLE_ZLIB)
  list(APPEND LLDB_SYSTEM_LIBS ZLIB::ZLIB)
endif()

to lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt or do you have different CMakeLists.txt file in mind ?

We should add this to LLDB_SYSTEM_LIBS like we do in lldb/source/Host/CMakeLists.txt and include ${LLDB_SYSTEM_LIBS} for lldbPluginProcessGDBRemote.

So should I add:

if(LLVM_ENABLE_ZLIB)
  list(APPEND LLDB_SYSTEM_LIBS ZLIB::ZLIB)
endif()

to lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt or do you have different CMakeLists.txt file in mind ?

Yup that's fine. I think at some point we'll want to centralize all these dependencies somewhere higher up and have it shared by the different targets, but that's definitely for a separate patch.

I tested this patch and it fixes lldb build. Thanks for taking care of this,.

mceier updated this revision to Diff 406706.Feb 7 2022, 10:16 PM

Updated diff to use LLDB_SYSTEM_LIBS

JDevlieghere accepted this revision.Feb 7 2022, 10:24 PM

Thanks! LGTM.

This revision is now accepted and ready to land.Feb 7 2022, 10:24 PM
mceier accepted this revision.Feb 7 2022, 11:01 PM

I need someone to merge it for me.

MaskRay added a subscriber: MaskRay.EditedFeb 7 2022, 11:22 PM

I need someone to merge it for me.

Testing and merging.

edit: merged into release/14.x as well.

Debian is still broken with this patch on -14:

lib/liblldbPluginProcessGDBRemote.a(GDBRemoteCommunication.cpp.o):GDBRemoteCommunication.cpp:function lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket(): error: undefined reference to 'inflateInit2_' lib/liblldbPluginProcessGDBRemote.a(GDBRemoteCommunication.cpp.o):GDBRemoteCommunication.cpp:function lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket(): error: undefined reference to 'inflate' lib/liblldbPluginProcessGDBRemote.a(GDBRemoteCommunication.cpp.o):GDBRemoteCommunication.cpp:function lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket(): error: undefined reference to 'inflateEnd'
mceier added a comment.Feb 8 2022, 2:25 AM

I downloaded build artifacts and it doesn't seem this patch was applied in this build. I grepped for ZLIB::ZLIB and only lld had it.