[Lldb-commits] [lldb] 2356bf2 - [lldb][CMake] Enforce not letting lldbUtility link against any other lldb libs

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 21 11:04:00 PDT 2023


Author: Alex Langford
Date: 2023-03-21T11:03:51-07:00
New Revision: 2356bf27f722eddbdf3c9acf4072cbdd348f00d0

URL: https://github.com/llvm/llvm-project/commit/2356bf27f722eddbdf3c9acf4072cbdd348f00d0
DIFF: https://github.com/llvm/llvm-project/commit/2356bf27f722eddbdf3c9acf4072cbdd348f00d0.diff

LOG: [lldb][CMake] Enforce not letting lldbUtility link against any other lldb libs

lldbUtility is not supposed to depend on anything else in lldb. Let's
enforce that constraint in CMake rather than hoping something doesn't
slip in under the radar.

Differential Revision: https://reviews.llvm.org/D146473

Added: 
    

Modified: 
    lldb/cmake/modules/AddLLDB.cmake
    lldb/source/Utility/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 374946fe49083..e8fa70a5a6848 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -37,13 +37,23 @@ function(add_lldb_library name)
   # only supported parameters to this macro are the optional
   # MODULE;SHARED;STATIC library type and source files
   cmake_parse_arguments(PARAM
-    "MODULE;SHARED;STATIC;OBJECT;PLUGIN;FRAMEWORK"
+    "MODULE;SHARED;STATIC;OBJECT;PLUGIN;FRAMEWORK;NO_INTERNAL_DEPENDENCIES"
     "INSTALL_PREFIX;ENTITLEMENTS"
     "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
     ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
 
+  if(PARAM_NO_INTERNAL_DEPENDENCIES)
+    foreach(link_lib ${PARAM_LINK_LIBS})
+      if (link_lib MATCHES "^lldb")
+        message(FATAL_ERROR
+          "Library ${name} cannot depend on any other lldb libs "
+          "(Found ${link_lib} in LINK_LIBS)")
+      endif()
+    endforeach()
+  endif()
+
   if(PARAM_PLUGIN)
     set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
   endif()

diff  --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt
index 89acd7cd2eaf5..c48ccdd7c1ed1 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -23,7 +23,7 @@ if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
     list(APPEND LLDB_SYSTEM_LIBS atomic)
 endif()
 
-add_lldb_library(lldbUtility
+add_lldb_library(lldbUtility NO_INTERNAL_DEPENDENCIES
   ArchSpec.cpp
   Args.cpp
   Baton.cpp


        


More information about the lldb-commits mailing list