[Lldb-commits] [lldb] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (PR #126715)
Michał Górny via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 11 03:20:48 PST 2025
https://github.com/mgorny created https://github.com/llvm/llvm-project/pull/126715
Use a preprocessor `#ifdef LLVM_BUILD_TELEMETRY` guard rather than `PARTIAL_SOURCES_INTENDED` for the `Telemetry.cpp` file, to fix building with telemetry disabled. `PARTIAL_SOURCES_INTENDED` does not currently work in `lldb_add_library()`, and while it could be fixed, it seems to be used contrary to its purpose — in other parts of LLVM project, the option is used to indicate that the sources found in the directory are split between different targets (e.g. a library and a tool), not to include sources conditionally.
>From 8ec53caddb1566d0d607c6e6321da7e960bf78cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny at gentoo.org>
Date: Tue, 11 Feb 2025 12:17:59 +0100
Subject: [PATCH] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY`
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use a preprocessor `#ifdef LLVM_BUILD_TELEMETRY` guard rather than
`PARTIAL_SOURCES_INTENDED` for the `Telemetry.cpp` file, to fix building
with telemetry disabled. `PARTIAL_SOURCES_INTENDED` does not currently
work in `lldb_add_library()`, and while it could be fixed, it seems
to be used contrary to its purpose — in other parts of LLVM project,
the option is used to indicate that the sources found in the directory
are split between different targets (e.g. a library and a tool),
not to include sources conditionally.
---
lldb/source/Core/CMakeLists.txt | 5 ++---
lldb/source/Core/Telemetry.cpp | 5 +++++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index 4b1f41816201608..fa79a40ac4bd4f0 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -17,8 +17,8 @@ if (LLDB_ENABLE_CURSES)
endif()
if (LLVM_BUILD_TELEMETRY)
- set(TELEMETRY_SOURCES Telemetry.cpp)
set(TELEMETRY_DEPS Telemetry)
+ add_definitions(-DLLVM_BUILD_TELEMETRY)
endif()
# TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore
@@ -57,11 +57,10 @@ add_lldb_library(lldbCore
SourceLocationSpec.cpp
SourceManager.cpp
StreamAsynchronousIO.cpp
+ Telemetry.cpp
ThreadedCommunication.cpp
UserSettingsController.cpp
Value.cpp
- ${TELEMETRY_SOURCES}
- PARTIAL_SOURCES_INTENDED
DEPENDS
clang-tablegen-targets
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index d479488bbc39949..adbef9655fcb62c 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -5,6 +5,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
+#ifdef LLVM_BUILD_TELEMETRY
+
#include "lldb/Core/Telemetry.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Utility/LLDBLog.h"
@@ -67,3 +70,5 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) {
} // namespace telemetry
} // namespace lldb_private
+
+#endif // LLVM_BUILD_TELEMETRY
More information about the lldb-commits
mailing list