Skip to content

Commit a22ad65

Browse files
authored
[lldb/cmake] Normalize use of HAVE_LIBCOMPRESSION (#135528)
I *think* this was the reason behind the failures in 2fd860c: the clang include tool showed the Config.h headers as unused, and because the macro was referenced through an `#ifdef`, its removal didn't cause build failures. Switching to `#cmakedefine01` + `#if` should make sure this does not happen again. According to D48977, the `#ifndef`+`#cmakedefine` patterns is due to some files redefining the macro themselves. I no longer see any such files in the source tree (there also were no files like that in the source tree at the revision mentioned, but the macro *was* defined in the hand-maintained XCode project we had at the time).
1 parent 8bc0d4d commit a22ad65

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

lldb/include/lldb/Host/Config.h.cmake

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
#cmakedefine01 HAVE_NR_PROCESS_VM_READV
2525

26-
#ifndef HAVE_LIBCOMPRESSION
27-
#cmakedefine HAVE_LIBCOMPRESSION
28-
#endif
26+
#cmakedefine01 HAVE_LIBCOMPRESSION
2927

3028
#cmakedefine01 LLDB_ENABLE_POSIX
3129

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define DEBUGSERVER_BASENAME "lldb-server"
4242
#endif
4343

44-
#if defined(HAVE_LIBCOMPRESSION)
44+
#if HAVE_LIBCOMPRESSION
4545
#include <compression.h>
4646
#endif
4747

@@ -72,7 +72,7 @@ GDBRemoteCommunication::~GDBRemoteCommunication() {
7272
Disconnect();
7373
}
7474

75-
#if defined(HAVE_LIBCOMPRESSION)
75+
#if HAVE_LIBCOMPRESSION
7676
if (m_decompression_scratch)
7777
free (m_decompression_scratch);
7878
#endif
@@ -509,7 +509,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
509509
}
510510
}
511511

512-
#if defined(HAVE_LIBCOMPRESSION)
512+
#if HAVE_LIBCOMPRESSION
513513
if (m_compression_type == CompressionType::ZlibDeflate ||
514514
m_compression_type == CompressionType::LZFSE ||
515515
m_compression_type == CompressionType::LZ4 ||

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class GDBRemoteCommunication : public Communication {
214214
HostThread m_listen_thread;
215215
std::string m_listen_url;
216216

217-
#if defined(HAVE_LIBCOMPRESSION)
217+
#if HAVE_LIBCOMPRESSION
218218
CompressionType m_decompression_scratch_type = CompressionType::None;
219219
void *m_decompression_scratch = nullptr;
220220
#endif

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_ZLIB
4242
#include "llvm/Support/JSON.h"
4343

44-
#if defined(HAVE_LIBCOMPRESSION)
44+
#if HAVE_LIBCOMPRESSION
4545
#include <compression.h>
4646
#endif
4747

@@ -1104,7 +1104,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
11041104
CompressionType avail_type = CompressionType::None;
11051105
llvm::StringRef avail_name;
11061106

1107-
#if defined(HAVE_LIBCOMPRESSION)
1107+
#if HAVE_LIBCOMPRESSION
11081108
if (avail_type == CompressionType::None) {
11091109
for (auto compression : supported_compressions) {
11101110
if (compression == "lzfse") {
@@ -1114,9 +1114,6 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
11141114
}
11151115
}
11161116
}
1117-
#endif
1118-
1119-
#if defined(HAVE_LIBCOMPRESSION)
11201117
if (avail_type == CompressionType::None) {
11211118
for (auto compression : supported_compressions) {
11221119
if (compression == "zlib-deflate") {
@@ -1140,7 +1137,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
11401137
}
11411138
#endif
11421139

1143-
#if defined(HAVE_LIBCOMPRESSION)
1140+
#if HAVE_LIBCOMPRESSION
11441141
if (avail_type == CompressionType::None) {
11451142
for (auto compression : supported_compressions) {
11461143
if (compression == "lz4") {
@@ -1150,9 +1147,6 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
11501147
}
11511148
}
11521149
}
1153-
#endif
1154-
1155-
#if defined(HAVE_LIBCOMPRESSION)
11561150
if (avail_type == CompressionType::None) {
11571151
for (auto compression : supported_compressions) {
11581152
if (compression == "lzma") {

0 commit comments

Comments
 (0)