[Lldb-commits] [lldb] 02572c6 - [lldb] Enforce that only the LLDB API unit tests can link liblldb (#162384)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 8 12:55:30 PDT 2025
Author: Jonas Devlieghere
Date: 2025-10-08T12:55:26-07:00
New Revision: 02572c6e9bbb60916ce471cbfec339b68a2121e2
URL: https://github.com/llvm/llvm-project/commit/02572c6e9bbb60916ce471cbfec339b68a2121e2
DIFF: https://github.com/llvm/llvm-project/commit/02572c6e9bbb60916ce471cbfec339b68a2121e2.diff
LOG: [lldb] Enforce that only the LLDB API unit tests can link liblldb (#162384)
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
Added:
Modified:
lldb/unittests/API/CMakeLists.txt
lldb/unittests/CMakeLists.txt
lldb/unittests/DAP/CMakeLists.txt
Removed:
################################################################################
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
More information about the lldb-commits
mailing list