[Lldb-commits] [lldb] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (PR #126715)

via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 11 03:21:24 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Michał Górny (mgorny)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/126715.diff


2 Files Affected:

- (modified) lldb/source/Core/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Core/Telemetry.cpp (+5) 


``````````diff
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index 4b1f4181620160..fa79a40ac4bd4f 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 d479488bbc3994..adbef9655fcb62 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

``````````

</details>


https://github.com/llvm/llvm-project/pull/126715


More information about the lldb-commits mailing list