Skip to content

Commit 159824c

Browse files
committed
[lldb/cmake] Normalize use of HAVE_LIBCOMPRESSION
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 f4fba20 commit 159824c

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#define DEBUGSERVER_BASENAME "lldb-server"
4747
#endif
4848

49-
#if defined(HAVE_LIBCOMPRESSION)
49+
#if HAVE_LIBCOMPRESSION
5050
#include <compression.h>
5151
#endif
5252

@@ -77,7 +77,7 @@ GDBRemoteCommunication::~GDBRemoteCommunication() {
7777
Disconnect();
7878
}
7979

80-
#if defined(HAVE_LIBCOMPRESSION)
80+
#if HAVE_LIBCOMPRESSION
8181
if (m_decompression_scratch)
8282
free (m_decompression_scratch);
8383
#endif
@@ -514,7 +514,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
514514
}
515515
}
516516

517-
#if defined(HAVE_LIBCOMPRESSION)
517+
#if HAVE_LIBCOMPRESSION
518518
if (m_compression_type == CompressionType::ZlibDeflate ||
519519
m_compression_type == CompressionType::LZFSE ||
520520
m_compression_type == CompressionType::LZ4 ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class GDBRemoteCommunication : public Communication {
227227
HostThread m_listen_thread;
228228
std::string m_listen_url;
229229

230-
#if defined(HAVE_LIBCOMPRESSION)
230+
#if HAVE_LIBCOMPRESSION
231231
CompressionType m_decompression_scratch_type = CompressionType::None;
232232
void *m_decompression_scratch = nullptr;
233233
#endif

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

Lines changed: 3 additions & 9 deletions
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)