Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrILToolsSubset=true</ClrRuntimeBuildSubsets>
</PropertyGroup>

<PropertyGroup Condition="$(_subset.Contains('+tools.cdacreader+'))">
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrCdacSubset=true</ClrRuntimeBuildSubsets>
</PropertyGroup>

<PropertyGroup Condition="$(_subset.Contains('+clr.nativeaotruntime+')) and '$(NativeAotSupported)' == 'true'">
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrNativeAotSubset=true</ClrRuntimeBuildSubsets>
</PropertyGroup>
Expand Down
15 changes: 5 additions & 10 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ function(install_static_library targetName destination component)
endif()
endfunction()

# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName] [INSTALL_ALL_ARTIFACTS])
# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName])
function(install_clr)
set(multiValueArgs TARGETS DESTINATIONS)
set(singleValueArgs COMPONENT)
set(options INSTALL_ALL_ARTIFACTS)
set(options "")
cmake_parse_arguments(INSTALL_CLR "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGV})

if ("${INSTALL_CLR_TARGETS}" STREQUAL "")
Expand Down Expand Up @@ -594,14 +594,9 @@ function(install_clr)
endif()

foreach(destination ${destinations})
# Install the export libraries for static libraries.
if (${INSTALL_CLR_INSTALL_ALL_ARTIFACTS})
install(TARGETS ${targetName} DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
else()
# We don't need to install the export libraries for our DLLs
# since they won't be directly linked against.
install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
endif()
# We don't need to install the export libraries for our DLLs
# since they won't be directly linked against.
install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
if (NOT "${symbolFile}" STREQUAL "")
install_symbol_file(${symbolFile} ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
endif()
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/components.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_component(iltools)
add_component(nativeaot)
add_component(spmi)
add_component(debug)
add_component(cdac)

# Define coreclr_all as the fallback component and make every component depend on this component.
# iltools and paltests should be minimal subsets, so don't add a dependency on coreclr_misc
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/debug/daccess/cdac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ namespace
path.Truncate(iter);
path.Append(CDAC_LIB_NAME);

#ifdef HOST_WINDOWS
// LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR tells the native windows loader to load dependencies
// from the same directory as cdacreader.dll. Once the native portions of the cDAC
// are statically linked, this won't be required.
*phCDAC = CLRLoadLibraryEx(path.GetUnicode(), NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
#else // !HOST_WINDOWS
*phCDAC = CLRLoadLibrary(path.GetUnicode());
#endif // HOST_WINDOWS
if (*phCDAC == NULL)
return false;

Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<_CoreClrBuildArg Condition="'$(ClrSpmiSubset)' == 'true'" Include="-component spmi" />
<_CoreClrBuildArg Condition="'$(ClrCrossComponentsSubset)' == 'true'" Include="-component crosscomponents" />
<_CoreClrBuildArg Condition="'$(ClrDebugSubset)' == 'true'" Include="-component debug" />
<_CoreClrBuildArg Condition="'$(ClrCdacSubset)' == 'true'" Include= "-component cdac" />
</ItemGroup>

<PropertyGroup Condition="('$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true') and '$(HostCrossOS)' == '' and '$(ANDROID_NDK_ROOT)' != ''">
Expand All @@ -85,8 +86,8 @@

<ItemGroup Condition="('$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true') and '$(HostCrossOS)' == '' and '$(ANDROID_NDK_ROOT)' != ''">
<_CoreClrBuildArg Include="-cmakeargs &quot;-DANDROID_STL=c++_static&quot;"/>
<!--

<!--
Only apply this setting on non-windows builds. Our windows build has a hard
time with a value that has spaces in it.
-->
Expand Down
68 changes: 54 additions & 14 deletions src/coreclr/unwinder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ add_dependencies(unwinder_dac eventing_headers)
set_target_properties(unwinder_dac PROPERTIES DAC_COMPONENT TRUE)
target_compile_definitions(unwinder_dac PRIVATE FEATURE_NO_HOST)

### cDAC Unwinders ####

set(BASE_UNWINDER_SOURCES baseunwinder.cpp)
convert_to_absolute_path(BASE_UNWINDER_SOURCES ${BASE_UNWINDER_SOURCES})
add_library_clr(unwinder_cdac_base STATIC ${BASE_UNWINDER_SOURCES})

target_include_directories(unwinder_cdac_base BEFORE PUBLIC ${VM_DIR})
target_include_directories(unwinder_cdac_base BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(unwinder_cdac_base BEFORE PUBLIC ${CLR_DIR}/unwinder)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/debug/ee)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/gc)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/gcdump)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/debug/daccess)
target_compile_definitions(unwinder_cdac_base PUBLIC FEATURE_NO_HOST FEATURE_CDAC_UNWINDER)

if (CLR_CMAKE_TARGET_WIN32)
# cDAC unwinders are statically linked into the NativeAOT runtime which is built with
# release version of the statically linked CRT. Therefore we do the same here.
set_property(TARGET unwinder_cdac_base PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded)

# _DEBUG is always passed as a parameter if the build is a debug build.
# This causes the debug CRT on MSVC to be used so we need to undefine it.
target_compile_options(unwinder_cdac_base PRIVATE -U_DEBUG)
endif()

install_clr(TARGETS unwinder_cdac_base DESTINATIONS cdaclibs COMPONENT cdac)

# Helper function for platform specific cDAC uwninder builds.
function(create_platform_unwinder)
set(oneValueArgs TARGET ARCH)
Expand All @@ -48,34 +75,47 @@ function(create_platform_unwinder)
clr_unknown_arch()
endif()

set(UNWINDER_SOURCES
baseunwinder.cpp
${ARCH_SOURCES_DIR}/unwinder.cpp
)

set(UNWINDER_SOURCES ${ARCH_SOURCES_DIR}/unwinder.cpp)
convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES})
add_library_clr(${TARGETDETAILS_TARGET} STATIC ${UNWINDER_SOURCES})

add_library_clr(${TARGETDETAILS_TARGET}
SHARED
${UNWINDER_SOURCES}
)
target_include_directories(${TARGETDETAILS_TARGET} BEFORE PRIVATE ${VM_DIR}/${ARCH_SOURCES_DIR})
target_include_directories(${TARGETDETAILS_TARGET} PRIVATE ${ARCH_SOURCES_DIR})

add_unwinder_include_directories(${TARGETDETAILS_TARGET})
target_link_libraries(${TARGETDETAILS_TARGET} PRIVATE unwinder_cdac_base)
if (CLR_CMAKE_TARGET_WIN32)
# cDAC unwinders are statically linked into the NativeAOT runtime which is built with
# release version of the statically linked CRT. Therefore we do the same here.
set_property(TARGET ${TARGETDETAILS_TARGET} PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded)

target_link_libraries(${TARGETDETAILS_TARGET} PRIVATE ${STATIC_MT_CRT_LIB} ${STATIC_MT_VCRT_LIB})
# _DEBUG is always passed as a parameter if the build is a debug build.
# This causes the debug CRT on MSVC to be used so we need to undefine it.
target_compile_options(${TARGETDETAILS_TARGET} PRIVATE -U_DEBUG)
endif()

# add the install targets
install_clr(TARGETS ${TARGETDETAILS_TARGET} DESTINATIONS ${TARGETDETAILS_DESTINATIONS} COMPONENT debug INSTALL_ALL_ARTIFACTS)
install_clr(TARGETS ${TARGETDETAILS_TARGET} DESTINATIONS ${TARGETDETAILS_DESTINATIONS} COMPONENT cdac)

# Set the target to be built for the specified OS and ARCH
set_target_definitions_to_custom_os_and_arch(TARGET ${TARGETDETAILS_TARGET} OS win ARCH ${TARGETDETAILS_ARCH})

target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_NO_HOST FEATURE_CDAC_UNWINDER)
endfunction()

# TODO: Support building cDAC unwinders on other platforms
# https://github.com/dotnet/runtime/issues/112272#issue-2838611496
if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
create_platform_unwinder(TARGET unwinder_cdac_amd64 ARCH x64 DESTINATIONS cdaclibs)
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)

if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)

if(NOT CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
create_platform_unwinder(TARGET unwinder_cdac_amd64 ARCH x64 DESTINATIONS cdaclibs)
endif(NOT CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)

if(NOT CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
endif(NOT CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)

12 changes: 6 additions & 6 deletions src/coreclr/unwinder/amd64/unwinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "baseunwinder.h"

#ifdef FEATURE_CDAC_UNWINDER
EXTERN_C __declspec(dllexport) BOOL amd64Unwind(void* pContext,
ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
EXTERN_C BOOL amd64Unwind(void* pContext,
ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
#endif // FEATURE_CDAC_UNWINDER

//---------------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/unwinder/arm64/unwinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "baseunwinder.h"

#ifdef FEATURE_CDAC_UNWINDER
EXTERN_C __declspec(dllexport) BOOL arm64Unwind(void* pContext, ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
EXTERN_C BOOL arm64Unwind(void* pContext, ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
#endif // FEATURE_CDAC_UNWINDER

//---------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/unwinder/baseunwinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ HRESULT OOPStackUnwinder::GetFunctionEntry( DWORD64 addres
_Out_writes_(cbBuffer) PVOID pBuffer,
DWORD cbBuffer)
{
#ifndef FEATURE_CDAC_UNWINDER
if (cbBuffer < sizeof(T_RUNTIME_FUNCTION))
{
return E_INVALIDARG;
}
#endif // FEATURE_CDAC_UNWINDER

PVOID pFuncEntry = NULL;
#ifndef FEATURE_CDAC_UNWINDER
Expand Down
2 changes: 0 additions & 2 deletions src/libraries/externals.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@
TODO: [cdac] Remove once cdacreader is added to shipping shared framework -->
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\*cdacreader*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\*cdacreader*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\cdaclibs\*unwinder_cdac*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\cdaclibs\PDB\*unwinder_cdac*" />
</ItemGroup>
<!-- If the build has native sanitizers, copy over the non-sanitized diagnostic binaries so they can be loaded by a debugger -->
<ItemGroup Condition="'$(EnableNativeSanitizers)' != ''">
Expand Down
15 changes: 9 additions & 6 deletions src/native/managed/cdacreader/src/cdacreader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
</ItemGroup>

<ItemGroup>
<!-- TODO: Link libraries on non-windows platforms. -->
<!-- https://github.com/dotnet/runtime/issues/112416 -->
<DirectPInvoke Include="unwinder_cdac_amd64" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'"/>
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_amd64.lib" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'" />
<DirectPInvoke Include="unwinder_cdac_arm64" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'"/>
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_arm64.lib" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'" />
<DirectPInvoke Include="unwinder_cdac_amd64" Condition="'$(TargetArchitecture)' == 'x64'" />
<DirectPInvoke Include="unwinder_cdac_arm64" Condition="'$(TargetArchitecture)' == 'arm64' or ('$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64')" />

<!-- unwinder_cdac_base is supported on all platforms -->
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\$(LibPrefix)unwinder_cdac_base$(StaticLibSuffix)" />

<!-- amd64 and arm64 are supported on windows x64, or on their native platform -->
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\$(LibPrefix)unwinder_cdac_amd64$(StaticLibSuffix)" Condition="'$(TargetArchitecture)' == 'x64'" />
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\$(LibPrefix)unwinder_cdac_arm64$(StaticLibSuffix)" Condition="'$(TargetArchitecture)' == 'arm64' or ('$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64')" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/tests/Common/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
<IncludeSubFolders>True</IncludeSubFolders>
</RunTimeArtifactsIncludeFolders>

<RuntimeArtifactsIncludeFolders Include="cdaclibs/" TargetDir="/">
<IncludeSubFolders>True</IncludeSubFolders>
</RuntimeArtifactsIncludeFolders>

<!-- XUnit runner harness assemblies that we don't want to mix in with the framework in Core_Root -->
<RunTimeArtifactsIncludeFolders Include="xunit/" TargetDir="xunit/" />
</ItemGroup>
Expand Down
Loading