[lldb][CMake] Enforce not linking against plugin libs in core libs

Non-plugin lldb libraries should generally not be linking against lldb
plugin libraries. Enforce this in CMake.

Differential Revision: https://reviews.llvm.org/D146553
This commit is contained in:
Alex Langford 2023-03-21 11:20:31 -07:00
parent 13e9afd16d
commit 5499b026d2
12 changed files with 22 additions and 10 deletions

View File

@ -37,7 +37,7 @@ 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;NO_INTERNAL_DEPENDENCIES"
"MODULE;SHARED;STATIC;OBJECT;PLUGIN;FRAMEWORK;NO_INTERNAL_DEPENDENCIES;NO_PLUGIN_DEPENDENCIES"
"INSTALL_PREFIX;ENTITLEMENTS"
"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
${ARGN})
@ -54,6 +54,16 @@ function(add_lldb_library name)
endforeach()
endif()
if(PARAM_NO_PLUGIN_DEPENDENCIES)
foreach(link_lib ${PARAM_LINK_LIBS})
if (link_lib MATCHES "^lldbPlugin")
message(FATAL_ERROR
"Library ${name} cannot depend on a plugin (Found ${link_lib} in "
"LINK_LIBS)")
endif()
endforeach()
endif()
if(PARAM_PLUGIN)
set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
endif()

View File

@ -1,4 +1,4 @@
add_lldb_library(lldbBreakpoint
add_lldb_library(lldbBreakpoint NO_PLUGIN_DEPENDENCIES
Breakpoint.cpp
BreakpointID.cpp
BreakpointIDList.cpp

View File

@ -2,7 +2,7 @@ lldb_tablegen(CommandOptions.inc -gen-lldb-option-defs
SOURCE Options.td
TARGET LLDBOptionsGen)
add_lldb_library(lldbCommands
add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
CommandCompletions.cpp
CommandObjectApropos.cpp
CommandObjectBreakpoint.cpp

View File

@ -19,6 +19,7 @@ if (LLDB_ENABLE_CURSES)
endif()
endif()
# TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore
add_lldb_library(lldbCore
Address.cpp
AddressRange.cpp

View File

@ -1,4 +1,4 @@
add_lldb_library(lldbDataFormatters
add_lldb_library(lldbDataFormatters NO_PLUGIN_DEPENDENCIES
CXXFunctionPointer.cpp
DataVisualization.cpp
DumpValueObjectOptions.cpp

View File

@ -1,3 +1,4 @@
# TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbExpression
add_lldb_library(lldbExpression
DiagnosticManager.cpp
DWARFExpression.cpp

View File

@ -159,7 +159,7 @@ if (LLDB_ENABLE_LIBEDIT)
endif()
endif()
add_lldb_library(lldbHost
add_lldb_library(lldbHost NO_PLUGIN_DEPENDENCIES
${HOST_SOURCES}
LINK_LIBS

View File

@ -2,7 +2,7 @@
remove_module_flags()
include_directories(..)
add_lldb_library(lldbHostMacOSXObjCXX
add_lldb_library(lldbHostMacOSXObjCXX NO_PLUGIN_DEPENDENCIES
Host.mm
HostInfoMacOSX.mm
HostThreadMacOSX.mm

View File

@ -6,7 +6,7 @@ lldb_tablegen(InterpreterPropertiesEnum.inc -gen-lldb-property-enum-defs
SOURCE InterpreterProperties.td
TARGET LLDBInterpreterPropertiesEnumGen)
add_lldb_library(lldbInterpreter
add_lldb_library(lldbInterpreter NO_PLUGIN_DEPENDENCIES
CommandAlias.cpp
CommandHistory.cpp
CommandInterpreter.cpp

View File

@ -6,7 +6,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
)
endif()
add_lldb_library(lldbSymbol
add_lldb_library(lldbSymbol NO_PLUGIN_DEPENDENCIES
ArmUnwindInfo.cpp
Block.cpp
CompactUnwindInfo.cpp

View File

@ -6,7 +6,7 @@ lldb_tablegen(TargetPropertiesEnum.inc -gen-lldb-property-enum-defs
SOURCE TargetProperties.td
TARGET LLDBTargetPropertiesEnumGen)
add_lldb_library(lldbTarget
add_lldb_library(lldbTarget NO_PLUGIN_DEPENDENCIES
ABI.cpp
AssertFrameRecognizer.cpp
DynamicRegisterInfo.cpp

View File

@ -36,7 +36,7 @@ set_source_files_properties("${version_inc}"
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_lldb_library(lldbVersion
add_lldb_library(lldbVersion NO_PLUGIN_DEPENDENCIES
Version.cpp
${vcs_version_inc}
${version_inc})