[Lldb-commits] [lldb] [lldb] Enforce that only the LLDB API unit tests can link liblldb (PR #162384)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 7 15:13:32 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Jonas Devlieghere (JDevlieghere)
<details>
<summary>Changes</summary>
Enforce that only specific tests can link liblldb. All the other unit tests statically link the private libraries. Linking both the static libraries and liblldb results in duplicated symbols.
Fixes #<!-- -->162378
---
Full diff: https://github.com/llvm/llvm-project/pull/162384.diff
3 Files Affected:
- (modified) lldb/unittests/API/CMakeLists.txt (+2)
- (modified) lldb/unittests/CMakeLists.txt (+5-1)
- (modified) lldb/unittests/DAP/CMakeLists.txt (+2)
``````````diff
diff --git a/lldb/unittests/API/CMakeLists.txt b/lldb/unittests/API/CMakeLists.txt
index 06ac49244176c..ea140a23af605 100644
--- a/lldb/unittests/API/CMakeLists.txt
+++ b/lldb/unittests/API/CMakeLists.txt
@@ -3,6 +3,8 @@ add_lldb_unittest(APITests
SBLineEntryTest.cpp
SBMutexTest.cpp
+ SBAPITEST
+
LINK_LIBS
liblldb
)
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index 4c5267ae25b74..194dd425430e2 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -12,7 +12,7 @@ endif()
function(add_lldb_unittest test_name)
cmake_parse_arguments(ARG
- ""
+ "SBAPITEST"
""
"LINK_LIBS;LINK_COMPONENTS"
${ARGN})
@@ -21,6 +21,10 @@ function(add_lldb_unittest test_name)
message(FATAL_ERROR "Unit test name must end with 'Tests' for lit to find it.")
endif()
+ if ("liblldb" IN_LIST ARG_LINK_LIBS AND NOT ARG_SBAPITEST)
+ message(FATAL_ERROR "The ${test_name} are not allowed to link liblldb.")
+ endif()
+
list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
add_unittest(LLDBUnitTests
diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt
index 716159b454231..a08414c30e6cd 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -12,6 +12,8 @@ add_lldb_unittest(DAPTests
TestBase.cpp
VariablesTest.cpp
+ SBAPITEST
+
LINK_COMPONENTS
Support
LINK_LIBS
``````````
</details>
https://github.com/llvm/llvm-project/pull/162384
More information about the lldb-commits
mailing list