[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 # only supported parameters to this macro are the optional
# MODULE;SHARED;STATIC library type and source files # MODULE;SHARED;STATIC library type and source files
cmake_parse_arguments(PARAM 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" "INSTALL_PREFIX;ENTITLEMENTS"
"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS" "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
${ARGN}) ${ARGN})
@ -54,6 +54,16 @@ function(add_lldb_library name)
endforeach() endforeach()
endif() 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) if(PARAM_PLUGIN)
set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name}) set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
endif() endif()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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