Skip to content

Commit d94a7f7

Browse files
committed
Integrate DNMD into the runtime repos build.
Convert testing harness to C++11. Convert DNMD PALs to use the minipal and the COM minipal. Integrate DNMD testing into the CLR_Tools_Tests job.
1 parent f73bb35 commit d94a7f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1887
-10956
lines changed

eng/Subsets.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
<SubsetName Include="Tools.ILLinkTests" OnDemand="true" Description="Unit tests for the tools.illink subset." />
183183

184184
<SubsetName Include="Tools.CdacReaderTests" OnDemand="true" Description="Units tests for the cDAC reader." />
185+
<SubsetName Include="Tools.NativeTests" OnDemand="true" Description="Native unit tests for native tools and libraries." />
185186

186187
<!-- Host -->
187188
<SubsetName Include="Host" Description="The .NET hosts, packages, hosting libraries, and tests. Equivalent to: $(DefaultHostSubsets)" />
@@ -409,6 +410,11 @@
409410
Test="true" Category="tools"/>
410411
</ItemGroup>
411412

413+
<ItemGroup Condition="$(_subset.Contains('+tools.nativetests+'))">
414+
<ProjectToBuild Include="$(RepoRoot)src\native\dnmd\dnmd.proj"
415+
Test="true" Category="tools" Condition="'$(DotNetBuildSourceOnly)' != 'true'"/>
416+
</ItemGroup>
417+
412418
<ItemGroup Condition="$(_subset.Contains('+clr.nativecorelib+'))">
413419
<ProjectToBuild Include="$(CoreClrProjectRoot)crossgen-corelib.proj" Category="clr" />
414420
</ItemGroup>

eng/native/configurecompiler.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ if (MSVC)
6060
define_property(TARGET PROPERTY CLR_EH_CONTINUATION INHERITED BRIEF_DOCS "Controls the /guard:ehcont flag presence" FULL_DOCS "Set this property to ON or OFF to indicate if the /guard:ehcont compiler flag should be present")
6161
define_property(TARGET PROPERTY CLR_EH_OPTION INHERITED BRIEF_DOCS "Defines the value of the /EH option" FULL_DOCS "Set this property to one of the valid /EHxx options (/EHa, /EHsc, /EHa-, ...)")
6262
define_property(TARGET PROPERTY MSVC_WARNING_LEVEL INHERITED BRIEF_DOCS "Define the warning level for the /Wn option" FULL_DOCS "Set this property to one of the valid /Wn options (/W0, /W1, /W2, /W3, /W4)")
63+
define_property(TARGET PROPERTY SET_SOURCE_CHARSET INHERITED BRIEF_DOCS "Add the /source-charset option" FULL_DOCS "Set this property to add the /source-charset:utf8 option")
6364

6465
set_property(GLOBAL PROPERTY CLR_CONTROL_FLOW_GUARD ON)
6566

@@ -881,7 +882,8 @@ if (MSVC)
881882

882883
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX,ASM_MASM>:/Zi>) # enable debugging information
883884
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/ZH:SHA_256>) # use SHA256 for generating hashes of compiler processed source files.
884-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/source-charset:utf-8>) # Force MSVC to compile source as UTF-8.
885+
set_property(GLOBAL PROPERTY SET_SOURCE_CHARSET ON)
886+
add_compile_options($<$<AND:$<BOOL:$<TARGET_PROPERTY:SET_SOURCE_CHARSET>>,$<COMPILE_LANGUAGE:C,CXX>>:/source-charset:utf-8>) # Force MSVC to compile source as UTF-8.
885887

886888
if (CLR_CMAKE_HOST_ARCH_I386)
887889
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gz>)

eng/pipelines/runtime.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,19 @@ extends:
692692
jobParameters:
693693
timeoutInMinutes: 120
694694
nameSuffix: CLR_Tools_Tests
695-
buildArgs: -s clr.aot+clr.iltools+libs.sfx+clr.toolstests+tools.cdacreadertests -c $(_BuildConfig) -test
695+
buildArgs: -s clr.aot+clr.iltools+libs.sfx+clr.toolstests+tools.cdacreadertests+tools.nativetests -c $(_BuildConfig) -test
696696
enablePublishTestResults: true
697697
testResultsFormat: 'xunit'
698+
postBuildSteps:
699+
- task: PublishTestResults@2
700+
displayName: 'Publish CTest Results'
701+
inputs:
702+
testResultsFormat: 'CTest'
703+
testResultsFiles: '*.ctestxml'
704+
searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
705+
testRunTitle: 'CLR_Tools_Tests-$(_BuildConfig)-ctest'
706+
continueOnError: true
707+
condition: always()
698708
# We want to run AOT tests when illink changes because there's share code and tests from illink which are used by AOT
699709
condition: >-
700710
or(

src/coreclr/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,17 @@ add_subdirectory(pal/prebuilt/inc)
125125
set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}")
126126
include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake)
127127

128+
#--------------------------------
129+
# Include shared native libraries
130+
#--------------------------------
128131
add_subdirectory(${CLR_SRC_NATIVE_DIR}/containers containers)
129132
add_subdirectory(${CLR_SRC_NATIVE_DIR}/eventpipe eventpipe)
130133
add_subdirectory(${CLR_SRC_NATIVE_DIR}/minipal shared_minipal)
131134

135+
if (NOT CLR_CROSS_COMPONENTS_BUILD)
136+
include(dnmd.cmake)
137+
endif()
138+
132139
if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
133140
add_subdirectory(debug/debug-pal)
134141
endif()

src/coreclr/build-runtime.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ for /f "delims=" %%a in ("-%__RequestedBuildComponents%-") do (
329329
if not "!string:-crosscomponents-=!"=="!string!" (
330330
set __CMakeTarget=!__CMakeTarget! crosscomponents
331331
)
332+
if not "!string:-cdac-=!"=="!string!" (
333+
set __CMakeTarget=!__CMakeTarget! cdac
334+
)
332335
if not "!string:-debug-=!"=="!string!" (
333336
set __CMakeTarget=!__CMakeTarget! debug
334337
)

src/coreclr/components.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ add_dependencies(runtime hosts)
2727

2828
# The cross-components build is separate, so we don't need to add a dependency on coreclr_misc
2929
add_component(crosscomponents)
30+
31+
# The cdac-components build is separate
32+
add_component(cdac)

src/coreclr/dnmd.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Include the dnmd project into the CoreCLR build
2+
include(FetchContent)
3+
FetchContent_Declare(
4+
dnmd
5+
SOURCE_DIR "${CLR_SRC_NATIVE_DIR}/dnmd"
6+
)
7+
8+
set(DNMD_BUILD_TESTS OFF)
9+
set(DNMD_INSTALL OFF)
10+
FetchContent_MakeAvailable(dnmd)
11+
12+
set_property(DIRECTORY ${CLR_SRC_NATIVE_DIR}/dnmd PROPERTY CLR_CONTROL_FLOW_GUARD ON)
13+
14+
# Install dnmd for usage by the cdac.
15+
install_static_library(dnmd cdac cdac)
16+
install_static_library(dnmd_interfaces_static cdac cdac)
17+
install(TARGETS dnmd_interfaces DESTINATION cdac COMPONENT cdac)
18+
add_dependencies(cdac dnmd_interfaces)

src/coreclr/inc/corhdr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,11 @@ typedef enum NativeTypeArrayFlags
17521752
//
17531753
// Enum used for HFA type recognition.
17541754
// Supported across architectures, so that it can be used in altjits and cross-compilation.
1755+
#ifdef __cplusplus
17551756
typedef enum CorInfoHFAElemType : unsigned {
1757+
#else
1758+
typedef enum CorInfoHFAElemType {
1759+
#endif
17561760
CORINFO_HFA_ELEM_NONE,
17571761
CORINFO_HFA_ELEM_FLOAT,
17581762
CORINFO_HFA_ELEM_DOUBLE,

src/native/dnmd/.github/workflows/main.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/native/dnmd/.github/workflows/publish-test-results.yml_disabled

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/native/dnmd/.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/native/dnmd/CMakeLists.txt

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.20)
22
project(dnmd
3-
LANGUAGES C CXX)
3+
LANGUAGES C)
44

5-
option(INCLUDE_VENDORED_LIBS "Include vendored libraries (submodules) instead of discovering dependencies through packages." ON)
5+
# Always include our public headers
6+
include_directories(src/inc)
7+
8+
# Include the metadata API headers provided by CoreCLR
9+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../coreclr/inc ${CMAKE_CURRENT_SOURCE_DIR}/../../coreclr/pal/prebuilt/inc)
610

7-
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
11+
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
12+
# This is our root CMakeList.txt, so we need to set up some global settings and include the minipal here.
13+
include(../../../eng/native/configurepaths.cmake)
14+
include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
815

9-
if (INCLUDE_VENDORED_LIBS)
10-
add_subdirectory(external/dncp)
11-
else()
12-
find_package(dncp REQUIRED)
16+
add_subdirectory(${CLR_SRC_NATIVE_DIR}/minipal minipal)
1317
endif()
1418

15-
include_directories(src/inc)
16-
include_directories(src/inc/external) # Hiding the "external" subdirectory due to uses of <...> in cor.h.
19+
include_directories(${CLR_SRC_NATIVE_DIR})
20+
21+
option(DNMD_BUILD_TESTS "Build tests for dnmd" ON)
22+
option(DNMD_INSTALL "Install dnmd targets" ON)
23+
option(DNMD_BUILD_INTERFACES "Build implementations of the metadata interfaces for DNMD" ON)
24+
option(DNMD_BUILD_TOOLS "Build tools for dnmd" ON)
25+
26+
if (DNMD_BUILD_INTERFACES OR DNMD_BUILD_TESTS OR DNMD_BUILD_TOOLS)
27+
enable_language(CXX)
28+
endif()
1729

1830
add_subdirectory(src/)
1931

20-
enable_testing()
2132

22-
add_subdirectory(test/)
33+
if (DNMD_BUILD_TESTS)
34+
enable_testing()
2335

36+
add_subdirectory(test/)
37+
endif()

src/native/dnmd/LICENSE.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)