Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move src/native libraries that are shared between runtime builds to be targets-driven #103184

Merged
merged 31 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8a3bb1c
Move containers library to be an object library instead of a list of …
jkoritzinsky Jun 6, 2024
0877350
Define default implementation of the simdhash assert failure function…
jkoritzinsky Jun 7, 2024
3adeb0f
Convert EventPipe and DiagnosticServer to be defined as interface lib…
jkoritzinsky Jun 7, 2024
39118f0
Move NativeAOT over to the new model as well.
jkoritzinsky Jun 7, 2024
b7e9e82
Move Mono to the new eventpipe model
jkoritzinsky Jun 7, 2024
82562ff
Remove old eventpipe model
jkoritzinsky Jun 8, 2024
7332da4
Use CMake's Unity Build support instead of our own hacked-together ve…
jkoritzinsky Jun 8, 2024
2f8f361
Flow dn_containers dependency
jkoritzinsky Jun 8, 2024
bf6bb47
Add a comment to explain the rationale for using an INTERFACE lib (as…
jkoritzinsky Jun 8, 2024
062aa32
PCH and UNITY_BUILD don't work together well
jkoritzinsky Jun 10, 2024
e32ce79
Don't build NativeAOT's EP runtime as a unity build, only the shared …
jkoritzinsky Jun 10, 2024
f428cee
Add another dependency for dn-containers to try to fix the android bu…
jkoritzinsky Jun 10, 2024
ed2a27e
Make the EXTERN_C_* macros into function-style macros
jkoritzinsky Jun 10, 2024
e6334b7
Namespace-scope our extern-c block define
jkoritzinsky Jun 11, 2024
847100d
Reference diagnosticserver pal in NativeAOT.
jkoritzinsky Jun 11, 2024
4969670
Fix Windows build in debug-pal and fix NativeAOT linkage issues.
jkoritzinsky Jun 14, 2024
292fac5
Correctly nest initializer for GCC
jkoritzinsky Jun 14, 2024
4d681a5
Just directly extern "C" the headers
jkoritzinsky Jun 14, 2024
81a686e
if not ifdef
jkoritzinsky Jun 14, 2024
5c13647
Try more directly including the container objects
jkoritzinsky Jun 14, 2024
44b7283
Fix other initialization syntax for GCC
jkoritzinsky Jun 14, 2024
f7f398b
Don't reference the diagnostic server PAL on cross-os builds
jkoritzinsky Jun 14, 2024
e08a371
Fix mono-aot-cross build
jkoritzinsky Jun 17, 2024
258221a
Fix win-x86 build.
jkoritzinsky Jun 19, 2024
60cc392
Try using TARGET_OBJECTS to fix the static component libraries
jkoritzinsky Jun 19, 2024
95f8383
Link dn-containers into Mono.framework
jkoritzinsky Jun 19, 2024
a0fb40b
Provide a no-lto flavor of the container library for NativeAOT. This …
jkoritzinsky Jun 19, 2024
78739e3
Make the default impl also cdecl
jkoritzinsky Jun 19, 2024
6d2b05f
Explicitly add eventpipe runtime objects to the static component library
jkoritzinsky Jun 19, 2024
d4ed370
Install compile PDBs for each of the EP libs used in NativeAOT
jkoritzinsky Jun 20, 2024
fc10257
Fix MSBuild build
jkoritzinsky Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ add_subdirectory(pal/prebuilt/inc)
set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}")
include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake)

add_subdirectory(${CLR_SRC_NATIVE_DIR}/containers containers)
add_subdirectory(${CLR_SRC_NATIVE_DIR}/eventpipe eventpipe)

if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory(debug/debug-pal)
endif()
Expand Down
21 changes: 12 additions & 9 deletions src/coreclr/debug/debug-pal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
include_directories(../inc)
include_directories(../../pal/inc)
include_directories(${EP_GENERATED_HEADER_PATH})

set(SHARED_EVENTPIPE_SOURCE_PATH ${CLR_SRC_NATIVE_DIR}/eventpipe)
add_definitions(-DFEATURE_CORECLR)
add_definitions(-DFEATURE_PERFTRACING)
add_definitions(-DFEATURE_PERFTRACING_STANDALONE_PAL)
Expand All @@ -12,9 +10,7 @@ if(CLR_CMAKE_HOST_WIN32)
include_directories(../../inc) #needed for warning control

if(CLR_CMAKE_TARGET_WIN32)
set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_SOURCE_PATH}/ds-ipc-pal-namedpipe.c")
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX)

set(DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER ON)
set(TWO_WAY_PIPE_SOURCES
${EVENTPIPE_PAL_SOURCES}
win/twowaypipe.cpp
Expand All @@ -28,14 +24,11 @@ if(CLR_CMAKE_HOST_WIN32)
endif(CLR_CMAKE_HOST_WIN32)

if(CLR_CMAKE_HOST_UNIX)
set(DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER ON)

add_definitions(-DPAL_IMPLEMENTATION)
add_definitions(-D_POSIX_C_SOURCE=200809L)

set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_SOURCE_PATH}/ds-ipc-pal-socket.c")
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)

set(TWO_WAY_PIPE_SOURCES
${EVENTPIPE_PAL_SOURCES}
unix/twowaypipe.cpp
Expand All @@ -45,3 +38,13 @@ if(CLR_CMAKE_HOST_UNIX)
endif(CLR_CMAKE_HOST_UNIX)

add_library_clr(debug-pal OBJECT ${TWO_WAY_PIPE_SOURCES})

if (DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER)
target_link_libraries(debug-pal PRIVATE dn-diagnosticserver-pal)

# The DiagnosticServer Runtime implementation in CoreCLR is C++,
# but the Diagnostic Server PAL is written in C.
# Override those files to build as C++.
get_property(ds_pal_sources TARGET dn-diagnosticserver-pal PROPERTY INTERFACE_SOURCES)
set_source_files_properties(${ds_pal_sources} PROPERTIES LANGUAGE CXX)
endif()
116 changes: 48 additions & 68 deletions src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,89 +106,28 @@ endif()

set(AOT_EVENTPIPE_SHIM_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

set (CONTAINER_SOURCES "")
set (CONTAINER_HEADERS "")
set (MINIPAL_SOURCES "")
set (EVENTPIPE_SOURCES "")
set (EVENTPIPE_HEADERS "")

# Use TCP for EventPipe on mobile platforms
if (CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID)
set(FEATURE_PERFTRACING_PAL_TCP 1)
set(FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT 1)
endif()

set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers")
set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe")
set (SHARED_MINIPAL_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/minipal")
include (${SHARED_EVENTPIPE_SOURCE_PATH}/eventpipe.cmake)
include (${SHARED_CONTAINERS_SOURCE_PATH}/containers.cmake)

list(APPEND MINIPAL_SOURCES
utf8.c
)

if(CLR_CMAKE_HOST_WIN32)
list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES
ds-ipc-pal-namedpipe.c
)

list(APPEND SHARED_DIAGNOSTIC_SERVER_HEADERS
ds-ipc-pal-namedpipe.h
)
endif(CLR_CMAKE_HOST_WIN32)

if(CLR_CMAKE_HOST_UNIX)
list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES
ds-ipc-pal-socket.c
)

list(APPEND SHARED_DIAGNOSTIC_SERVER_HEADERS
ds-ipc-pal-socket.h
)

include(${CLR_SRC_NATIVE_DIR}/minipal/configure.cmake)
list(APPEND MINIPAL_SOURCES
random.c
)

endif(CLR_CMAKE_HOST_UNIX)

list(APPEND EVENTPIPE_SOURCES
${SHARED_EVENTPIPE_SOURCES}
${SHARED_DIAGNOSTIC_SERVER_SOURCES}
)

list(APPEND EVENTPIPE_HEADERS
${SHARED_EVENTPIPE_HEADERS}
${SHARED_DIAGNOSTIC_SERVER_HEADERS}
)

addprefix(CONTAINER_SOURCES ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_SOURCES}")
addprefix(CONTAINER_HEADERS ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_HEADERS}")
addprefix(MINIPAL_SOURCES ${SHARED_MINIPAL_SOURCE_PATH} "${MINIPAL_SOURCES}")

addprefix(EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_SOURCES}")
addprefix(EVENTPIPE_HEADERS ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_HEADERS}")

set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES)
set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES)

set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES LANGUAGE CXX)

if(CLR_CMAKE_HOST_UNIX)
set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)
set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)
endif(CLR_CMAKE_HOST_UNIX)

if (CLR_CMAKE_TARGET_WIN32)
set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_FLAGS "/FI\"${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h\"")
endif()

list(APPEND AOT_EVENTPIPE_SHIM_SOURCES
${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-aot.cpp
${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-aot.cpp
${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-aot.cpp
)

list(APPEND AOT_EVENTPIPE_SHIM_HEADERS
Expand Down Expand Up @@ -229,18 +168,56 @@ if (FEATURE_EVENT_TRACE)
endif()
endif()


# The NativeAOT EventPipe runtime is C++, but the EventPipe and DiagnosticServer sources are C.
# Forcibly override them to build as C++.
get_property(diagnosticserver_sources TARGET dn-diagnosticserver PROPERTY INTERFACE_SOURCES)
get_property(diagnosticserver_pal_sources TARGET dn-diagnosticserver-pal PROPERTY INTERFACE_SOURCES)
get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES)
set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX)

add_library(eventpipe-shared-objects OBJECT)
target_link_libraries(eventpipe-shared-objects PRIVATE dn-diagnosticserver dn-eventpipe dn-diagnosticserver-pal)
# Build EventPipe and DiagnosticServer as unity-builds for better inlining.
set_target_properties(eventpipe-shared-objects PROPERTIES
UNITY_BUILD ON
UNITY_BUILD_BATCH_SIZE 0
COMPILE_PDB_NAME "eventpipe-shared-objects"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>"
)
if (CLR_CMAKE_TARGET_WIN32)
add_library(eventpipe-shared-objects.GuardCF OBJECT)
target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-diagnosticserver dn-eventpipe dn-diagnosticserver-pal)

target_compile_options(eventpipe-shared-objects PRIVATE
"/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h")

target_compile_options(eventpipe-shared-objects.GuardCF PRIVATE
"/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h")

# Build EventPipe and DiagnosticServer as unity-builds for better inlining.
set_target_properties(eventpipe-shared-objects.GuardCF PROPERTIES
UNITY_BUILD ON
UNITY_BUILD_BATCH_SIZE 0
CLR_CONTROL_FLOW_GUARD ON
COMPILE_PDB_NAME "eventpipe-shared-objects.GuardCF"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")

# Install the compile PDB for the eventpipe unity builds.
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/eventpipe-shared-objects.pdb" DESTINATION aotsdk COMPONENT nativeaot)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/eventpipe-shared-objects.GuardCF.pdb" DESTINATION aotsdk COMPONENT nativeaot)
# For the container library, we need to produce a compile PDB and install it
set_target_properties(dn-containers-no-lto PROPERTIES
COMPILE_PDB_NAME "dn-containers"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/dn-containers.pdb" DESTINATION aotsdk COMPONENT nativeaot)
endif()

list(APPEND EVENTPIPE_SOURCES
${AOT_EVENTPIPE_SHIM_SOURCES}
${AOT_EVENTPIPE_SHIM_HEADERS}
${AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES}
${AOT_EVENTTRACE_SOURCES}
${SHARED_EVENTPIPE_CONFIG_HEADERS}
${GEN_EVENTPIPE_PROVIDER_SOURCES}
${GEN_EVENTPIPE_PLAT_AGNOSTIC_SOURCES}
${CONTAINER_SOURCES}
${CONTAINER_HEADERS}
${MINIPAL_SOURCES}
)

Expand All @@ -253,6 +230,8 @@ list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES
)

add_library(eventpipe-enabled STATIC ${EVENTPIPE_SOURCES})

target_link_libraries(eventpipe-enabled PRIVATE eventpipe-shared-objects dn-containers-no-lto)
add_dependencies(eventpipe-enabled aot_eventing_headers)
if(CLR_CMAKE_TARGET_WIN32)
add_dependencies(eventpipe-enabled aot_etw_headers)
Expand All @@ -263,6 +242,7 @@ add_dependencies(eventpipe-disabled aot_eventing_headers)

if (CLR_CMAKE_TARGET_WIN32)
add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES})
target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF dn-containers-no-lto)
add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers)
add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers)
add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES})
Expand All @@ -276,4 +256,4 @@ install_static_library(eventpipe-disabled aotsdk nativeaot)
if (CLR_CMAKE_TARGET_WIN32)
install_static_library(eventpipe-enabled.GuardCF aotsdk nativeaot)
install_static_library(eventpipe-disabled.GuardCF aotsdk nativeaot)
endif (CLR_CMAKE_TARGET_WIN32)
endif (CLR_CMAKE_TARGET_WIN32)
75 changes: 17 additions & 58 deletions src/coreclr/vm/eventing/eventpipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,6 @@ add_custom_command(OUTPUT ${GEN_EVENTPIPE_SOURCES}
COMMAND ${GENERATE_COMMAND}
DEPENDS ${GENERATE_SCRIPT} ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS})

set (CONTAINER_SOURCES "")
set (CONTAINER_HEADERS "")
set (EVENTPIPE_SOURCES "")
set (EVENTPIPE_HEADERS "")
set (CORECLR_EVENTPIPE_SHIM_SOURCES "")
set (CORECLR_EVENTPIPE_SHIM_HEADERS "")

set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers")
set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe")
set (CORECLR_EVENTPIPE_SHIM_SOURCE_PATH "${CORECLR_EVENTPIPE_SHIM_DIR}")

include (${SHARED_CONTAINERS_SOURCE_PATH}/containers.cmake)
include (${SHARED_EVENTPIPE_SOURCE_PATH}/eventpipe.cmake)

list(APPEND EVENTPIPE_SOURCES
${SHARED_EVENTPIPE_SOURCES}
${SHARED_DIAGNOSTIC_SERVER_SOURCES}
)

list(APPEND EVENTPIPE_HEADERS
${SHARED_EVENTPIPE_HEADERS}
${SHARED_DIAGNOSTIC_SERVER_HEADERS}
)

addprefix(CONTAINER_SOURCES ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_SOURCES}")
addprefix(CONTAINER_HEADERS ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_HEADERS}")

addprefix(EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_SOURCES}")
addprefix(EVENTPIPE_HEADERS ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_HEADERS}")

set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES)
set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES)

set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES LANGUAGE CXX)

if(CLR_CMAKE_HOST_UNIX)
set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)
set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)
endif(CLR_CMAKE_HOST_UNIX)

list(APPEND CORECLR_EVENTPIPE_SHIM_SOURCES
ep-rt-coreclr.cpp
)
Expand All @@ -81,28 +40,28 @@ list(APPEND CORECLR_EVENTPIPE_SHIM_HEADERS
ep-rt-types-coreclr.h
)

addprefix(CORECLR_EVENTPIPE_SHIM_SOURCES ${CORECLR_EVENTPIPE_SHIM_SOURCE_PATH} "${CORECLR_EVENTPIPE_SHIM_SOURCES}")
addprefix(CORECLR_EVENTPIPE_SHIM_HEADERS ${CORECLR_EVENTPIPE_SHIM_SOURCE_PATH} "${CORECLR_EVENTPIPE_SHIM_HEADERS}")


list(APPEND EVENTPIPE_SOURCES
${CORECLR_EVENTPIPE_SHIM_SOURCES}
${CORECLR_EVENTPIPE_SHIM_HEADERS}
${EVENTPIPE_HEADERS}
${SHARED_EVENTPIPE_CONFIG_HEADERS}
${CONTAINER_SOURCES}
${CONTAINER_HEADERS}
)

add_library_clr(eventpipe_gen_objs OBJECT ${GEN_EVENTPIPE_SOURCES})
target_precompile_headers(eventpipe_gen_objs PRIVATE [["common.h"]])
set_target_properties(eventpipe_gen_objs PROPERTIES LINKER_LANGUAGE CXX)
add_dependencies(eventpipe_gen_objs eventing_headers)

add_library_clr(eventpipe_objs OBJECT ${EVENTPIPE_SOURCES})
target_precompile_headers(eventpipe_objs PRIVATE [["common.h"]])
set_target_properties(eventpipe_objs PROPERTIES LINKER_LANGUAGE CXX)
add_library_clr(eventpipe_objs OBJECT ${CORECLR_EVENTPIPE_SHIM_SOURCES} ${CORECLR_EVENTPIPE_SHIM_HEADERS})
set_target_properties(eventpipe_objs PROPERTIES
LINKER_LANGUAGE CXX
UNITY_BUILD ON
UNITY_BUILD_BATCH_SIZE 0
)
add_dependencies(eventpipe_objs eventing_headers)
target_link_libraries(eventpipe_objs PRIVATE dn-diagnosticserver dn-eventpipe)

# The CoreCLR EventPipe runtime is C++, but the EventPipe and DiagnosticServer sources are C.
# Forcibly override them to build as C++.
get_property(diagnosticserver_sources TARGET dn-diagnosticserver PROPERTY INTERFACE_SOURCES)
get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES)
set_source_files_properties(${diagnosticserver_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX)

# Build EventPipe and DiagnosticServer as unity-builds.
set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe")

add_library(eventpipe INTERFACE)
target_sources(eventpipe INTERFACE $<TARGET_OBJECTS:eventpipe_gen_objs> $<TARGET_OBJECTS:eventpipe_objs>)
target_sources(eventpipe INTERFACE $<TARGET_OBJECTS:eventpipe_gen_objs> $<TARGET_OBJECTS:eventpipe_objs> $<TARGET_OBJECTS:dn-containers>)
27 changes: 26 additions & 1 deletion src/mono/mono/component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ set(MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME "diagnostics_tracing")
set(MONO_DEBUGGER_COMPONENT_NAME "debugger")
set(MONO_MARSHAL_ILGEN_COMPONENT_NAME "marshal-ilgen")

add_subdirectory(${SHARED_CONTAINERS_SOURCE_PATH} containers)
add_subdirectory(${SHARED_EVENTPIPE_SOURCE_PATH} eventpipe)

# a list of every component.
set(components "")
# a list of components needed by the AOT compiler
Expand Down Expand Up @@ -70,7 +73,6 @@ include_directories(
)

set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-sources
${container_sources}
${eventpipe_sources}
${diagnostic_server_sources}
${MONO_COMPONENT_PATH}/event_pipe.c
Expand Down Expand Up @@ -213,6 +215,29 @@ elseif(AOT_COMPONENTS OR (NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS))

endif()

if (ENABLE_PERFTRACING AND "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}" IN_LIST components_to_build)
# Build EventPipe and DiagnosticServer with the Mono runtime implementation as unity-builds.
add_library(eventpipe-mono-objects OBJECT)
set_target_properties(
eventpipe-mono-objects
PROPERTIES
UNITY_BUILD ON
UNITY_BUILD_BATCH_SIZE 0
)
target_link_libraries(eventpipe-mono-objects PRIVATE component_base eglib_api dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal)
# Link the diagnostics_tracing component to the EventPipe and DiagnosticServer libraries.
if (TARGET ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects)
target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $<TARGET_OBJECTS:eventpipe-mono-objects> $<TARGET_OBJECTS:dn-containers>)
list(APPEND mono-components-objects $<TARGET_OBJECTS:eventpipe-mono-objects> $<TARGET_OBJECTS:dn-containers>)
endif()
if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static)
target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static PRIVATE $<TARGET_OBJECTS:eventpipe-mono-objects> $<TARGET_OBJECTS:dn-containers>)
endif()
if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME})
target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE $<TARGET_OBJECTS:eventpipe-mono-objects> $<TARGET_OBJECTS:dn-containers>)
endif()
endif()

# define a list of mono-components-stubs objects that will be linked into
# the runtime to be used as fallbacks if the dynamic components are not
# available or when only static component stubs are requested.
Expand Down
Loading
Loading