diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 578ee25d3bd7e6..575fbb52ad2362 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -228,10 +228,16 @@ if (ENABLE_PERFTRACING AND "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}" IN_LIST # 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 $ $) - list(APPEND mono-components-objects $ $) + # If we are going to link the diagnostics component via mono-components-objects, link in the supporting object libraries as well. + string(REPLACE + "$" + "$;$;$" + mono-components-objects "${mono-components-objects}") endif() if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static) - target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static PRIVATE $ $) + # We don't add dn-containers here as any scenario that uses this target will also use the monosgen-static target, + # which will also have dn-containers linked into it. + target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static PRIVATE $) endif() if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}) target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE $ $)