Skip to content

[lldb] Use preprocessor guard for LLVM_BUILD_TELEMETRY #126715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

mgorny
Copy link
Member

@mgorny mgorny commented Feb 11, 2025

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.

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.
@mgorny mgorny requested review from oontvoo and labath February 11, 2025 11:20
@mgorny mgorny requested a review from JDevlieghere as a code owner February 11, 2025 11:20
@llvmbot llvmbot added the lldb label Feb 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 11, 2025

@llvm/pr-subscribers-lldb

Author: Michał Górny (mgorny)

Changes

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 --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

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's fine, though I'm still fairly disappointed that we have to do this...

@mgorny mgorny merged commit bf2d4eb into llvm:main Feb 11, 2025
7 checks passed
@mgorny mgorny deleted the lldb-telemetry-sources branch February 11, 2025 14:22
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
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.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
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.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants