[lldb/cmake] Normalize use of HAVE_LIBCOMPRESSION (#135528)

I *think* this was the reason behind the failures in
2fd860c1f5: 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).
This commit is contained in:
Pavel Labath
2025-04-22 10:14:03 +02:00
committed by GitHub
parent 8bc0d4d1cc
commit a22ad659cd
4 changed files with 8 additions and 16 deletions

View File

@@ -23,9 +23,7 @@
#cmakedefine01 HAVE_NR_PROCESS_VM_READV #cmakedefine01 HAVE_NR_PROCESS_VM_READV
#ifndef HAVE_LIBCOMPRESSION #cmakedefine01 HAVE_LIBCOMPRESSION
#cmakedefine HAVE_LIBCOMPRESSION
#endif
#cmakedefine01 LLDB_ENABLE_POSIX #cmakedefine01 LLDB_ENABLE_POSIX

View File

@@ -41,7 +41,7 @@
#define DEBUGSERVER_BASENAME "lldb-server" #define DEBUGSERVER_BASENAME "lldb-server"
#endif #endif
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
#include <compression.h> #include <compression.h>
#endif #endif
@@ -72,7 +72,7 @@ GDBRemoteCommunication::~GDBRemoteCommunication() {
Disconnect(); Disconnect();
} }
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
if (m_decompression_scratch) if (m_decompression_scratch)
free (m_decompression_scratch); free (m_decompression_scratch);
#endif #endif
@@ -509,7 +509,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
} }
} }
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
if (m_compression_type == CompressionType::ZlibDeflate || if (m_compression_type == CompressionType::ZlibDeflate ||
m_compression_type == CompressionType::LZFSE || m_compression_type == CompressionType::LZFSE ||
m_compression_type == CompressionType::LZ4 || m_compression_type == CompressionType::LZ4 ||

View File

@@ -214,7 +214,7 @@ private:
HostThread m_listen_thread; HostThread m_listen_thread;
std::string m_listen_url; std::string m_listen_url;
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
CompressionType m_decompression_scratch_type = CompressionType::None; CompressionType m_decompression_scratch_type = CompressionType::None;
void *m_decompression_scratch = nullptr; void *m_decompression_scratch = nullptr;
#endif #endif

View File

@@ -41,7 +41,7 @@
#include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_ZLIB #include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_ZLIB
#include "llvm/Support/JSON.h" #include "llvm/Support/JSON.h"
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
#include <compression.h> #include <compression.h>
#endif #endif
@@ -1104,7 +1104,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
CompressionType avail_type = CompressionType::None; CompressionType avail_type = CompressionType::None;
llvm::StringRef avail_name; llvm::StringRef avail_name;
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
if (avail_type == CompressionType::None) { if (avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "lzfse") { if (compression == "lzfse") {
@@ -1114,9 +1114,6 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
} }
} }
} }
#endif
#if defined(HAVE_LIBCOMPRESSION)
if (avail_type == CompressionType::None) { if (avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "zlib-deflate") { if (compression == "zlib-deflate") {
@@ -1140,7 +1137,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
} }
#endif #endif
#if defined(HAVE_LIBCOMPRESSION) #if HAVE_LIBCOMPRESSION
if (avail_type == CompressionType::None) { if (avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "lz4") { if (compression == "lz4") {
@@ -1150,9 +1147,6 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
} }
} }
} }
#endif
#if defined(HAVE_LIBCOMPRESSION)
if (avail_type == CompressionType::None) { if (avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "lzma") { if (compression == "lzma") {