From 8d6cd81d8e3b0bfd602a321b582cf3d272842128 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 5 Apr 2021 15:05:34 -0700 Subject: [PATCH] Reorganize CoreCLR native build to reduce CMake reconfigures when the build system is untouched (#49906) --- eng/Subsets.props | 17 ++- eng/native/build-commons.sh | 30 ++-- eng/native/functions.cmake | 166 ++++++++++++--------- eng/native/gen-buildsys.cmd | 26 +++- eng/native/gen-buildsys.sh | 13 ++ eng/native/set-cmake-path.ps1 | 7 +- eng/pipelines/coreclr/templates/build-job.yml | 2 +- src/coreclr/CMakeLists.txt | 109 ++++++-------- src/coreclr/ToolBox/SOS/CMakeLists.txt | 2 +- src/coreclr/ToolBox/superpmi/mcs/CMakeLists.txt | 5 +- .../superpmi-shim-collector/CMakeLists.txt | 6 +- .../superpmi/superpmi-shim-counter/CMakeLists.txt | 6 +- .../superpmi/superpmi-shim-simple/CMakeLists.txt | 6 +- .../ToolBox/superpmi/superpmi/CMakeLists.txt | 6 +- src/coreclr/_build-commons.sh | 2 +- src/coreclr/build-runtime.cmd | 47 ++++-- src/coreclr/build-runtime.sh | 47 +++--- src/coreclr/components.cmake | 21 +++ src/coreclr/crosscomponents.cmake | 26 ++-- src/coreclr/debug/createdump/CMakeLists.txt | 8 +- src/coreclr/debug/debug-pal/CMakeLists.txt | 2 +- src/coreclr/debug/runtimeinfo/CMakeLists.txt | 2 +- src/coreclr/dlls/clretwrc/CMakeLists.txt | 2 +- src/coreclr/dlls/dbgshim/CMakeLists.txt | 2 +- src/coreclr/dlls/mscordac/CMakeLists.txt | 6 +- src/coreclr/dlls/mscordbi/CMakeLists.txt | 2 +- src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt | 4 +- src/coreclr/dlls/mscorrc/CMakeLists.txt | 2 +- src/coreclr/gc/CMakeLists.txt | 2 +- src/coreclr/gc/sample/CMakeLists.txt | 2 +- src/coreclr/gcinfo/CMakeLists.txt | 33 ++-- src/coreclr/hosts/corerun/CMakeLists.txt | 4 +- src/coreclr/hosts/coreshim/CMakeLists.txt | 2 +- src/coreclr/ilasm/CMakeLists.txt | 4 +- src/coreclr/ildasm/exe/CMakeLists.txt | 4 +- src/coreclr/inc/CMakeLists.txt | 4 +- src/coreclr/jit/CMakeLists.txt | 59 ++++---- src/coreclr/nativeresources/CMakeLists.txt | 2 +- src/coreclr/pal/CMakeLists.txt | 6 +- src/coreclr/pal/prebuilt/inc/CMakeLists.txt | 2 +- src/coreclr/pal/src/CMakeLists.txt | 2 +- .../src/eventprovider/lttngprovider/CMakeLists.txt | 9 +- src/coreclr/pal/tests/palsuite/CMakeLists.txt | 9 +- .../tests/palsuite/eventprovider/CMakeLists.txt | 6 +- .../pal_sxs/test1/CMakeLists.txt | 13 +- src/coreclr/palrt/CMakeLists.txt | 2 +- src/coreclr/runtime.proj | 13 +- src/coreclr/tools/CMakeLists.txt | 4 +- .../tools/GenClrDebugResource/CMakeLists.txt | 2 +- src/coreclr/tools/InjectResource/CMakeLists.txt | 2 +- src/coreclr/tools/aot/jitinterface/CMakeLists.txt | 3 +- src/coreclr/tools/crossgen/CMakeLists.txt | 2 +- src/coreclr/vm/CMakeLists.txt | 14 +- src/coreclr/vm/eventing/CMakeLists.txt | 5 +- .../System.Globalization.Native/CMakeLists.txt | 2 +- .../System.IO.Compression.Native/CMakeLists.txt | 2 +- .../Unix/System.IO.Ports.Native/CMakeLists.txt | 2 +- .../Native/Unix/System.Native/CMakeLists.txt | 2 +- .../Unix/System.Net.Security.Native/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- src/libraries/Native/Windows/CMakeLists.txt | 8 +- .../System.IO.Compression.Native/CMakeLists.txt | 4 +- src/libraries/Native/build-native.cmd | 1 - src/libraries/Native/build-native.sh | 4 +- src/mono/dbi/CMakeLists.txt | 3 + src/native/corehost/apphost/static/CMakeLists.txt | 4 + src/native/corehost/build.sh | 2 +- src/native/corehost/exe.cmake | 2 +- src/native/corehost/setup.cmake | 2 +- src/tests/build.sh | 2 +- 71 files changed, 450 insertions(+), 380 deletions(-) create mode 100644 src/coreclr/components.cmake diff --git a/eng/Subsets.props b/eng/Subsets.props index 6e9f9bf..5d1b874 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -42,7 +42,7 @@ - clr.runtime+clr.jit+clr.alljits+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.iltools+clr.packages + clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages mono.llvm+ mono.llvm+ @@ -81,8 +81,9 @@ - - + + + @@ -146,14 +147,18 @@ - + - $(ClrRuntimeBuildSubsets);ClrRuntimeSubset=true;ClrJitSubset=true + $(ClrRuntimeBuildSubsets);ClrRuntimeSubset=true + + + + $(ClrRuntimeBuildSubsets);ClrFullNativeBuild=true @@ -165,7 +170,7 @@ - $(ClrRuntimeBuildSubsets);ClrAllJitsSubset=true;ClrJitSubset=true + $(ClrRuntimeBuildSubsets);ClrAllJitsSubset=true diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 4771ec7..63ffbba 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -72,11 +72,12 @@ build_native() platformArch="$2" cmakeDir="$3" intermediatesDir="$4" - cmakeArgs="$5" - message="$6" + target="$5" + cmakeArgs="$6" + message="$7" # All set to commence the build - echo "Commencing build of \"$message\" for $__TargetOS.$__BuildArch.$__BuildType in $intermediatesDir" + echo "Commencing build of \"$target\" target in \"$message\" for $__TargetOS.$__BuildArch.$__BuildType in $intermediatesDir" if [[ "$targetOS" == OSX || "$targetOS" == MacCatalyst ]]; then if [[ "$platformArch" == x64 ]]; then @@ -188,20 +189,29 @@ EOF pushd "$intermediatesDir" buildTool="$SCAN_BUILD_COMMAND -o $__BinDir/scan-build-log $buildTool" - echo "Executing $buildTool install -j $__NumProc" - "$buildTool" install -j "$__NumProc" + echo "Executing $buildTool $target -j $__NumProc" + "$buildTool" $target -j "$__NumProc" exit_code="$?" popd else cmake_command=cmake if [[ "$build_arch" == "wasm" ]]; then - cmake_command="emcmake $cmake_command" - fi + cmake_command="emcmake cmake" + echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" + $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" + exit_code="$?" + else + # For non-wasm Unix scenarios, we may have to use an old version of CMake that doesn't support + # multiple targets. Instead, directly invoke the build tool to build multiple targets in one invocation. + pushd "$intermediatesDir" - echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -- -j $__NumProc" - $cmake_command --build "$intermediatesDir" --target install -- -j "$__NumProc" - exit_code="$?" + echo "Executing $buildTool $target -j $__NumProc" + "$buildTool" $target -j "$__NumProc" + exit_code="$?" + + popd + fi fi CFLAGS="${SAVED_CFLAGS}" diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index ae4c660..3519706 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -206,6 +206,27 @@ function(compile_asm) set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE) endfunction() +# add_component(componentName [targetName] [EXCLUDE_FROM_ALL]) +function(add_component componentName) + if (${ARGC} GREATER 2 OR ${ARGC} EQUAL 2) + set(componentTargetName "${ARGV1}") + else() + set(componentTargetName "${componentName}") + endif() + if (${ARGC} EQUAL 3 AND "${ARG2}" STREQUAL "EXCLUDE_FROM_ALL") + set(exclude_from_all_flag "EXCLUDE_FROM_ALL") + endif() + get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS) + list (FIND definedComponents "${componentName}" componentIndex) + if (${componentIndex} EQUAL -1) + list (APPEND definedComponents "${componentName}") + add_custom_target("${componentTargetName}" + COMMAND "${CMAKE_COMMAND}" "-DCMAKE_INSTALL_COMPONENT=${componentName}" "-DBUILD_TYPE=$" -P "${CMAKE_BINARY_DIR}/cmake_install.cmake" + ${exclude_from_all_flag}) + set_property(GLOBAL PROPERTY CLR_CMAKE_COMPONENTS ${definedComponents}) + endif() +endfunction() + function(generate_exports_file) set(INPUT_LIST ${ARGN}) list(GET INPUT_LIST -1 outputFilename) @@ -248,12 +269,29 @@ function(generate_exports_file_prefix inputFilename outputFilename prefix) PROPERTIES GENERATED TRUE) endfunction() +function (get_symbol_file_name targetName outputSymbolFilename) + if (CLR_CMAKE_HOST_UNIX) + if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + set(strip_destination_file $.dwarf) + else () + set(strip_destination_file $.dbg) + endif () + + set(${outputSymbolFilename} ${strip_destination_file} PARENT_SCOPE) + else(CLR_CMAKE_HOST_UNIX) + # We can't use the $ generator expression here since + # the generator expression isn't supported on resource DLLs. + set(${outputSymbolFilename} $/$$.pdb PARENT_SCOPE) + endif(CLR_CMAKE_HOST_UNIX) +endfunction() + function(strip_symbols targetName outputFilename) + get_symbol_file_name(${targetName} strip_destination_file) + set(${outputFilename} ${strip_destination_file} PARENT_SCOPE) if (CLR_CMAKE_HOST_UNIX) set(strip_source_file $) if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - set(strip_destination_file ${strip_source_file}.dwarf) # Ensure that dsymutil and strip are present find_program(DSYMUTIL dsymutil) @@ -282,7 +320,6 @@ function(strip_symbols targetName outputFilename) COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) else (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - set(strip_destination_file ${strip_source_file}.dbg) add_custom_command( TARGET ${targetName} @@ -294,26 +331,13 @@ function(strip_symbols targetName outputFilename) COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) endif (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - - set(${outputFilename} ${strip_destination_file} PARENT_SCOPE) - else(CLR_CMAKE_HOST_UNIX) - get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(is_multi_config) - # We can't use the $ generator expression here since - # the generator expression isn't supported on resource DLLs. - set(${outputFilename} ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pdb PARENT_SCOPE) - else() - # We can't use the $ generator expression here since - # the generator expression isn't supported on resource DLLs. - set(${outputFilename} ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pdb PARENT_SCOPE) - endif() endif(CLR_CMAKE_HOST_UNIX) endfunction() function(install_with_stripped_symbols targetName kind destination) if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS) strip_symbols(${targetName} symbol_file) - install_symbols(${symbol_file} ${destination}) + install_symbol_file(${symbol_file} ${destination} ${ARGN}) endif() if ((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND ("${kind}" STREQUAL "TARGETS")) @@ -328,59 +352,75 @@ function(install_with_stripped_symbols targetName kind destination) else() message(FATAL_ERROR "The `kind` argument has to be either TARGETS or PROGRAMS, ${kind} was provided instead") endif() - install(${kind} ${install_source} DESTINATION ${destination}) + install(${kind} ${install_source} DESTINATION ${destination} ${ARGN}) endfunction() -function(install_symbols symbol_file destination_path) +function(install_symbol_file symbol_file destination_path) if(CLR_CMAKE_TARGET_WIN32) - install(FILES ${symbol_file} DESTINATION ${destination_path}/PDB) + install(FILES ${symbol_file} DESTINATION ${destination_path}/PDB ${ARGN}) else() - install(FILES ${symbol_file} DESTINATION ${destination_path}) + install(FILES ${symbol_file} DESTINATION ${destination_path} ${ARGN}) endif() endfunction() -# install_clr(TARGETS TARGETS targetName [targetName2 ...] [ADDITIONAL_DESTINATIONS destination]) +# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName]) function(install_clr) - set(multiValueArgs TARGETS ADDITIONAL_DESTINATIONS) - cmake_parse_arguments(INSTALL_CLR "" "" "${multiValueArgs}" ${ARGV}) + set(multiValueArgs TARGETS DESTINATIONS) + set(singleValueArgs COMPONENT) + set(options "") + cmake_parse_arguments(INSTALL_CLR "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGV}) if ("${INSTALL_CLR_TARGETS}" STREQUAL "") message(FATAL_ERROR "At least one target must be passed to install_clr(TARGETS )") endif() - set(destinations ".") + if ("${INSTALL_CLR_DESTINATIONS}" STREQUAL "") + message(FATAL_ERROR "At least one destination must be passed to install_clr.") + endif() + + set(destinations "") + + if (NOT "${INSTALL_CLR_DESTINATIONS}" STREQUAL "") + list(APPEND destinations ${INSTALL_CLR_DESTINATIONS}) + endif() - if (NOT "${INSTALL_CLR_ADDITIONAL_DESTINATIONS}" STREQUAL "") - list(APPEND destinations ${INSTALL_CLR_ADDITIONAL_DESTINATIONS}) + if ("${INSTALL_CLR_COMPONENT}" STREQUAL "") + set(INSTALL_CLR_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) endif() foreach(targetName ${INSTALL_CLR_TARGETS}) - list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX) - if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1) - if (NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS) - strip_symbols(${targetName} symbol_file) - endif() + if (NOT "${INSTALL_CLR_COMPONENT}" STREQUAL "${targetName}") + get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS) + list(FIND definedComponents "${INSTALL_CLR_COMPONENT}" componentIdx) + if (${componentIdx} EQUAL -1) + message(FATAL_ERROR "The ${INSTALL_CLR_COMPONENT} component is not defined. Add a call to `add_component(${INSTALL_CLR_COMPONENT})` to define the component in the build.") + endif() + add_dependencies(${INSTALL_CLR_COMPONENT} ${targetName}) + endif() + get_target_property(targetType ${targetName} TYPE) + if (NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS AND NOT "${targetType}" STREQUAL "STATIC") + get_symbol_file_name(${targetName} symbol_file) + endif() - foreach(destination ${destinations}) - # We don't need to install the export libraries for our DLLs - # since they won't be directly linked against. - install(PROGRAMS $ DESTINATION ${destination}) - if (NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS) - install_symbols(${symbol_file} ${destination}) - endif() + foreach(destination ${destinations}) + # We don't need to install the export libraries for our DLLs + # since they won't be directly linked against. + install(PROGRAMS $ DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT}) + if (NOT "${symbolFile}" STREQUAL "") + install_symbol_file(${symbol_file} ${destination} COMPONENT ${INSTALL_CLR_COMPONENT}) + endif() - if(CLR_CMAKE_PGO_INSTRUMENT) - if(WIN32) - get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(is_multi_config) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL) - else() - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL) - endif() - endif() + if(CLR_CMAKE_PGO_INSTRUMENT) + if(WIN32) + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL COMPONENT ${INSTALL_CLR_COMPONENT}) + else() + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL COMPONENT ${INSTALL_CLR_COMPONENT}) endif() - endforeach() - endif() + endif() + endif() + endforeach() endforeach() endfunction() @@ -427,45 +467,29 @@ if (CMAKE_VERSION VERSION_LESS "3.16") endfunction() endif() -function(_add_executable) +function(add_executable_clr) if(NOT WIN32) add_executable(${ARGV} ${VERSION_FILE_PATH}) disable_pax_mprotect(${ARGV}) else() add_executable(${ARGV}) endif(NOT WIN32) - list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX) - if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1) - set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1) + if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS) + strip_symbols(${ARGV0} symbolFile) endif() endfunction() -function(_add_library) +function(add_library_clr) if(NOT WIN32 AND "${ARGV1}" STREQUAL "SHARED") add_library(${ARGV} ${VERSION_FILE_PATH}) else() add_library(${ARGV}) endif(NOT WIN32 AND "${ARGV1}" STREQUAL "SHARED") - list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX) - if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1) - set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1) - endif() -endfunction() - -function(_install) - if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) - install(${ARGV}) + if("${ARGV1}" STREQUAL "SHARED" AND NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS) + strip_symbols(${ARGV0} symbolFile) endif() endfunction() -function(add_library_clr) - _add_library(${ARGV}) -endfunction() - -function(add_executable_clr) - _add_executable(${ARGV}) -endfunction() - # add_linker_flag(Flag [Config1 Config2 ...]) function(add_linker_flag Flag) if (ARGN STREQUAL "") diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index d4b0ba8..2d81dd1 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -30,7 +30,7 @@ if /i "%__Ninja%" == "1" ( if /i NOT "%__Arch%" == "wasm" ( if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019) if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017) - + if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64) if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM) if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64) @@ -67,10 +67,32 @@ goto loop set __ExtraCmakeParams="-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams% +set __CmdLineOptionsUpToDateFile=%__IntermediatesDir%\cmake_cmd_line.txt +set __CMakeCmdLineCache= +if not "%__ConfigureOnly%" == "1" ( + REM MSBuild can't reload from a CMake reconfigure during build correctly, so only do this + REM command-line up to date check for non-VS generators. + if not "%__CmakeGenerator%" == "Visual Studio" ( + if exist "%__CmdLineOptionsUpToDateFile%" ( + set /p __CMakeCmdLineCache=<"%__CmdLineOptionsUpToDateFile%" + REM Strip the extra space from the end of the cached command line + if [!__ExtraCmakeParams!] == [!__CMakeCmdLineCache:~0,-1!] ( + echo The CMake command line is the same as the last run. Skipping running CMake. + exit /B 0 + ) else ( + echo The CMake command line differs from the last run. Running CMake again. + echo %__ExtraCmakeParams% > %__CmdLineOptionsUpToDateFile% + ) + ) else ( + echo %__ExtraCmakeParams% > %__CmdLineOptionsUpToDateFile% + ) + ) +) + if /i "%__UseEmcmake%" == "1" ( call "!EMSDK_PATH!/emsdk_env.bat" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir% ) else ( - "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir% + "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir% ) endlocal exit /B %errorlevel% diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index f852ae0..f671182 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -97,6 +97,19 @@ if [[ "$build_arch" == "wasm" ]]; then cmake_command="emcmake $cmake_command" fi +cmake_args_to_cache="$scan_build\n$SCAN_BUILD_COMMAND\n$generator\n$__UnprocessedCMakeArgs" +cmake_args_cache_file="$__CMakeBinDir/cmake_cmd_line.txt" +if [[ -z "$__ConfigureOnly" ]]; then + if [[ -e "$cmake_args_cache_file" ]]; then + cmake_args_cache=$(<"$cmake_args_cache_file") + if [[ "$cmake_args_cache" == "$cmake_args_to_cache" ]]; then + echo "CMake command line is unchanged. Reusing previous cache instead of regenerating." + exit 0 + fi + fi + echo $cmake_args_to_cache > $cmake_args_cache_file +fi + # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options pushd "$2" diff --git a/eng/native/set-cmake-path.ps1 b/eng/native/set-cmake-path.ps1 index 57f0e64..d83ce5a 100644 --- a/eng/native/set-cmake-path.ps1 +++ b/eng/native/set-cmake-path.ps1 @@ -35,11 +35,8 @@ try { $version = [Version]$(& $cmakePath --version | Select-String -Pattern '\d+\.\d+\.\d+' | %{$_.Matches.Value}) - if ($version -lt [Version]"3.14.0") { - throw "This repository requires CMake 3.14 and recommends CMake 3.16. The version of CMake installed is $version. Please install CMake 3.16 or newer from https://cmake.org/download/." - } - elseif ($version -lt [Version]"3.16.4") { - [System.Console]::Error.WriteLine("CMake 3.16.4 or newer is recommended for building this repository. The newest version of CMake installed is $version. Please install CMake 3.16.4 or newer from https://cmake.org/download/.") + if ($version -lt [Version]"3.16.4") { + throw "CMake 3.16.4 or newer is required for building this repository. The newest version of CMake installed is $version. Please install CMake 3.16.4 or newer from https://cmake.org/download/." } [System.Console]::WriteLine("set CMakePath=" + $cmakePath) diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index 4766c5c..3727b27 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -130,7 +130,7 @@ jobs: value: '' - ${{ if ne(parameters.testGroup, 'innerloop') }}: - name: clrBuildPALTestsBuildArg - value: '-paltests ' + value: '-component runtime -component alljits -component paltests ' - name: pgoInstrumentArg value: '' diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 8dc3564..8f82d83 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -38,7 +38,11 @@ OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF) # Cross target Component build specific configuration #---------------------------------------------------- if(CLR_CROSS_COMPONENTS_BUILD) - include(crosscomponents.cmake) + add_definitions(-DCROSS_COMPILE) + + if(CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_I386)) + set(FEATURE_CROSSBITNESS 1) + endif(CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_I386)) endif(CLR_CROSS_COMPONENTS_BUILD) #------------------- @@ -46,13 +50,19 @@ endif(CLR_CROSS_COMPONENTS_BUILD) #------------------- include(pgosupport.cmake) +#--------------------------------------------------- +# Define sub-component targets for the build +#--------------------------------------------------- +include(components.cmake) + #--------------------------- # Build the single file host #--------------------------- -if(CLR_CMAKE_BUILD_SUBSET_RUNTIME AND NOT CLR_CROSS_COMPONENTS_BUILD) +if(NOT CLR_CROSS_COMPONENTS_BUILD) + set(CLR_SINGLE_FILE_HOST_ONLY 1) add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) + add_dependencies(runtime singlefilehost) endif() - #------------------------- # Enable C++ EH with SEH #------------------------- @@ -64,7 +74,7 @@ endif() #------------------------------- # Include libraries native shims #------------------------------- -if(NOT CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_BUILD_SUBSET_RUNTIME) +if(NOT CLR_CROSS_COMPONENTS_BUILD) set(STATIC_LIBS_ONLY 1) if(CLR_CMAKE_TARGET_WIN32) @@ -72,7 +82,7 @@ if(NOT CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_BUILD_SUBSET_RUNTIME) else() add_subdirectory(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix Native.Unix) endif() -endif(NOT CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_BUILD_SUBSET_RUNTIME) +endif(NOT CLR_CROSS_COMPONENTS_BUILD) #----------------------------------------- # Add Projects @@ -93,9 +103,7 @@ if(CLR_CMAKE_HOST_UNIX) endif() add_subdirectory(pal) - if(CLR_CMAKE_BUILD_SUBSET_RUNTIME) - add_subdirectory(hosts) - endif(CLR_CMAKE_BUILD_SUBSET_RUNTIME) + add_subdirectory(hosts) else(CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_TARGET_UNIX) add_subdirectory(pal/src/libunwind) @@ -107,7 +115,7 @@ add_subdirectory(pal/prebuilt/inc) add_subdirectory(debug/debug-pal) -if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_BUILD_SUBSET_RUNTIME) +if(CLR_CMAKE_TARGET_WIN32) add_subdirectory(gc/sample) endif() @@ -118,9 +126,8 @@ endif() include_directories("pal/prebuilt/inc") include_directories("../../artifacts/obj/coreclr") -if(CLR_CMAKE_BUILD_SUBSET_JIT) - add_subdirectory(tools/aot/jitinterface) -endif(CLR_CMAKE_BUILD_SUBSET_JIT) +add_subdirectory(tools/aot/jitinterface) + # Above projects do not build with these compile options # All of the compiler options are specified in file compileoptions.cmake @@ -138,9 +145,7 @@ include(clrdefinitions.cmake) if(FEATURE_STANDALONE_GC) add_definitions(-DFEATURE_STANDALONE_GC) - if (CLR_CMAKE_BUILD_SUBSET_RUNTIME) - add_subdirectory(gc) - endif (CLR_CMAKE_BUILD_SUBSET_RUNTIME) + add_subdirectory(gc) endif(FEATURE_STANDALONE_GC) if (CLR_CMAKE_HOST_UNIX) @@ -170,11 +175,9 @@ endif(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE) add_subdirectory(debug/dbgutil) if(CLR_CMAKE_HOST_UNIX) - if(CLR_CMAKE_BUILD_SUBSET_RUNTIME) - if(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)) - add_subdirectory(debug/createdump) - endif(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)) - endif(CLR_CMAKE_BUILD_SUBSET_RUNTIME) + if(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)) + add_subdirectory(debug/createdump) + endif(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)) # Include the dummy c++ include files include_directories("pal/inc/rt/cpp") @@ -225,44 +228,28 @@ if(CLR_CMAKE_HOST_UNIX) add_subdirectory(palrt) endif(CLR_CMAKE_HOST_UNIX) -if(CLR_CMAKE_BUILD_SUBSET_ILTOOLS) - add_subdirectory(ildasm) - add_subdirectory(ilasm) -endif(CLR_CMAKE_BUILD_SUBSET_ILTOOLS) - -if(CLR_CMAKE_BUILD_SUBSET_JIT) - add_subdirectory(gcinfo) - add_subdirectory(jit) - add_subdirectory(vm) -else(CLR_CMAKE_BUILD_SUBSET_JIT) - # The eventing headers are required to build the IL tools and paltests - add_subdirectory(vm/eventing) -endif(CLR_CMAKE_BUILD_SUBSET_JIT) - -if (CLR_CMAKE_BUILD_SUBSET_RUNTIME) - add_subdirectory(md) - add_subdirectory(debug) - add_subdirectory(binder) - add_subdirectory(classlibnative) - add_subdirectory(dlls) - add_subdirectory(ToolBox) - add_subdirectory(tools) - add_subdirectory(unwinder) - add_subdirectory(interop) - - if(CLR_CMAKE_HOST_WIN32) - add_subdirectory(hosts) - endif(CLR_CMAKE_HOST_WIN32) -elseif(CLR_CMAKE_BUILD_SUBSET_ILTOOLS) - # These parts of the runtime are required to build the IL tools - add_subdirectory(md) - add_subdirectory(dlls/mscorrc) - add_subdirectory(dlls/mscorpe) -elseif(CLR_CMAKE_BUILD_SUBSET_JIT) - if(CLR_CMAKE_HOST_UNIX) - # this is needed to compile the jit on unix platforms. - # When the runtime subset is compiled, the add_subdirectory(dlls) above - # brings the mscorrc library into the build graph - add_subdirectory(dlls/mscorrc) - endif(CLR_CMAKE_HOST_UNIX) -endif(CLR_CMAKE_BUILD_SUBSET_RUNTIME) +add_subdirectory(ilasm) +add_subdirectory(ildasm) +add_subdirectory(gcinfo) +add_subdirectory(jit) +add_subdirectory(vm) +add_subdirectory(md) +add_subdirectory(debug) +add_subdirectory(binder) +add_subdirectory(classlibnative) +add_subdirectory(dlls) +add_subdirectory(ToolBox) +add_subdirectory(tools) +add_subdirectory(unwinder) +add_subdirectory(interop) + +if(CLR_CMAKE_HOST_WIN32) + add_subdirectory(hosts) +endif(CLR_CMAKE_HOST_WIN32) + +#---------------------------------------------------- +# Cross target Component install configuration +#---------------------------------------------------- +if(CLR_CROSS_COMPONENTS_BUILD) + include(crosscomponents.cmake) +endif(CLR_CROSS_COMPONENTS_BUILD) diff --git a/src/coreclr/ToolBox/SOS/CMakeLists.txt b/src/coreclr/ToolBox/SOS/CMakeLists.txt index 1474c54..a8b5112 100644 --- a/src/coreclr/ToolBox/SOS/CMakeLists.txt +++ b/src/coreclr/ToolBox/SOS/CMakeLists.txt @@ -1 +1 @@ -_install(FILES SOS_README.md DESTINATION .) +install(FILES SOS_README.md DESTINATION .) diff --git a/src/coreclr/ToolBox/superpmi/mcs/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/mcs/CMakeLists.txt index e928c48..56dcaff 100644 --- a/src/coreclr/ToolBox/superpmi/mcs/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/mcs/CMakeLists.txt @@ -47,7 +47,7 @@ set(MCS_SOURCES ../superpmi-shared/spmidumphelper.cpp ) -_add_executable(mcs +add_executable_clr(mcs ${MCS_SOURCES} ) target_precompile_headers(mcs PRIVATE "$<$:standardpch.h>") @@ -66,7 +66,6 @@ else() ${STATIC_MT_CPP_LIB} ) - _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (TARGETS mcs DESTINATION .) +install_clr(TARGETS mcs DESTINATIONS .) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt index 27ab467..1eb640c 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt @@ -39,7 +39,7 @@ if (CLR_CMAKE_TARGET_WIN32) list(APPEND SUPERPMI_SHIM_COLLECTOR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-collector.def) endif (CLR_CMAKE_TARGET_WIN32) -_add_library(superpmi-shim-collector +add_library_clr(superpmi-shim-collector SHARED ${SUPERPMI_SHIM_COLLECTOR_SOURCES} ) @@ -59,8 +59,6 @@ else() ${STATIC_MT_CRT_LIB} ${STATIC_MT_CPP_LIB} ) - - _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (PROGRAMS $ DESTINATION .) +install_clr(TARGETS superpmi-shim-collector DESTINATIONS .) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt index 57a42a5..602a675 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt @@ -41,7 +41,7 @@ if (CLR_CMAKE_TARGET_WIN32) list(APPEND SUPERPMI_SHIM_COUNTER_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-counter.def) endif (CLR_CMAKE_TARGET_WIN32) -_add_library(superpmi-shim-counter +add_library_clr(superpmi-shim-counter SHARED ${SUPERPMI_SHIM_COUNTER_SOURCES} ) @@ -61,8 +61,6 @@ else() ${STATIC_MT_CRT_LIB} ${STATIC_MT_CPP_LIB} ) - - _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (PROGRAMS $ DESTINATION .) +install_clr(TARGETS superpmi-shim-counter DESTINATIONS .) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt index 58afa78..b6f4d52 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt @@ -40,7 +40,7 @@ if (CLR_CMAKE_TARGET_WIN32) list(APPEND SUPERPMI_SHIM_SIMPLE_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-simple.def) endif (CLR_CMAKE_TARGET_WIN32) -_add_library(superpmi-shim-simple +add_library_clr(superpmi-shim-simple SHARED ${SUPERPMI_SHIM_SIMPLE_SOURCES} ) @@ -60,8 +60,6 @@ else() ${STATIC_MT_CRT_LIB} ${STATIC_MT_CPP_LIB} ) - - _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (PROGRAMS $ DESTINATION .) +install_clr(TARGETS superpmi-shim-simple DESTINATIONS .) diff --git a/src/coreclr/ToolBox/superpmi/superpmi/CMakeLists.txt b/src/coreclr/ToolBox/superpmi/superpmi/CMakeLists.txt index 3bc6ca8..92cda6d 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi/CMakeLists.txt +++ b/src/coreclr/ToolBox/superpmi/superpmi/CMakeLists.txt @@ -41,7 +41,7 @@ set(SUPERPMI_SOURCES ../superpmi-shared/spmidumphelper.cpp ) -_add_executable(superpmi +add_executable_clr(superpmi ${SUPERPMI_SOURCES} ) @@ -61,8 +61,6 @@ else() ${STATIC_MT_CRT_LIB} ${STATIC_MT_CPP_LIB} ) - - _install (FILES $ DESTINATION PDB) endif(CLR_CMAKE_HOST_UNIX) -_install (TARGETS superpmi DESTINATION .) +install_clr(TARGETS superpmi DESTINATIONS .) diff --git a/src/coreclr/_build-commons.sh b/src/coreclr/_build-commons.sh index 8bac206..9b1ee88 100755 --- a/src/coreclr/_build-commons.sh +++ b/src/coreclr/_build-commons.sh @@ -23,7 +23,7 @@ handle_arguments() { ;; *) - handle_arguments_local "$1" + handle_arguments_local "$1" "$2" ;; esac } diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index e31d9b7..25cffd3 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -68,17 +68,13 @@ set __BuildCrossArchNative=0 set __SkipCrossArchNative=0 set __SkipGenerateVersion=0 set __RestoreOptData=1 -set __BuildJit=1 -set __BuildPALTests=0 -set __BuildAllJits=1 -set __BuildRuntime=1 -set __BuildILTools=1 set __CrossArch= set __CrossArch2= set __CrossOS=0 set __PgoOptDataPath= set __CMakeArgs= set __Ninja=1 +set __RequestedBuildComponents= @REM CMD has a nasty habit of eating "=" on the argument list, so passing: @REM -priority=1 @@ -158,10 +154,7 @@ if /i "%1" == "-msbuild" (set __Ninja=0&set processedArgs=!processed if /i "%1" == "-pgoinstrument" (set __PgoInstrument=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-enforcepgo" (set __EnforcePgo=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-skipjit" (set __BuildJit=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-skipalljits" (set __BuildAllJits=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-skipruntime" (set __BuildRuntime=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-skipiltools" (set __BuildILTools=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-component" (set __RequestedBuildComponents=%__RequestedBuildComponents%-%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) REM TODO these are deprecated remove them eventually REM don't add more, use the - syntax instead @@ -423,7 +416,28 @@ if NOT DEFINED PYTHON ( goto ExitWithError ) -set __CMakeClrBuildSubsetArgs="-DCLR_CMAKE_BUILD_SUBSET_JIT=%__BuildJit%" "-DCLR_CMAKE_BUILD_SUBSET_ALLJITS=%__BuildAllJits%" "-DCLR_CMAKE_BUILD_SUBSET_RUNTIME=%__BuildRuntime%" "-DCLR_CMAKE_BUILD_SUBSET_ILTOOLS=%__BuildILTools%" +set __CMakeTarget= +for /f "delims=" %%a in ("-%__RequestedBuildComponents%-") do ( + set "string=%%a" + if not "!string:-jit-=!"=="!string!" ( + set __CMakeTarget=!__CMakeTarget! jit + ) + if not "!string:-alljits-=!"=="!string!" ( + set __CMakeTarget=!__CMakeTarget! alljits + ) + if not "!string:-runtime-=!"=="!string!" ( + set __CMakeTarget=!__CMakeTarget! runtime + ) + if not "!string:-paltests-=!"=="!string!" ( + set __CMakeTarget=!__CMakeTarget! paltests_install + ) + if not "!string:-iltools-=!"=="!string!" ( + set __CMakeTarget=!__CMakeTarget! iltools + ) +) +if [!__CMakeTarget!] == [] ( + set __CMakeTarget=install +) REM ========================================================================================= REM === @@ -455,7 +469,7 @@ if %__BuildCrossArchNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - set __ExtraCmakeArgs=!__ExtraCmakeArgs! %__CMakeClrBuildSubsetArgs% "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" %__CMakeArgs% + set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" %__CMakeArgs% call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( @@ -492,7 +506,7 @@ if %__BuildCrossArchNative% EQU 1 ( set __CmakeBuildToolArgs=/nologo /m !__Logging! ) - "%CMakePath%" --build %__CrossCompIntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs! + "%CMakePath%" --build %__CrossCompIntermediatesDir% --target crosscomponents --config %__BuildType% -- !__CmakeBuildToolArgs! if not !errorlevel! == 0 ( set __exitCode=!errorlevel! @@ -529,7 +543,7 @@ if %__BuildCrossArchNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - set __ExtraCmakeArgs=!__ExtraCmakeArgs! %__CMakeClrBuildSubsetArgs% "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCMAKE_SYSTEM_VERSION=10.0" %__CMakeArgs% + set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCMAKE_SYSTEM_VERSION=10.0" %__CMakeArgs% call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossComp2IntermediatesDir%" %__VSVersion% %__CrossArch2% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( @@ -567,7 +581,7 @@ if %__BuildCrossArchNative% EQU 1 ( set __CmakeBuildToolArgs=/nologo /m !__Logging! ) - "%CMakePath%" --build %__CrossComp2IntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs! + "%CMakePath%" --build %__CrossComp2IntermediatesDir% --target crosscomponents --config %__BuildType% -- !__CmakeBuildToolArgs! if not !errorlevel! == 0 ( set __exitCode=!errorlevel! @@ -621,7 +635,7 @@ if %__BuildNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - set __ExtraCmakeArgs=!__ExtraCmakeArgs! !___CrossBuildDefine! %__CMakeClrBuildSubsetArgs% "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% + set __ExtraCmakeArgs=!__ExtraCmakeArgs! !___CrossBuildDefine! "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project! @@ -657,7 +671,8 @@ if %__BuildNative% EQU 1 ( set __CmakeBuildToolArgs=/nologo /m !__Logging! ) - "%CMakePath%" --build %__IntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs! + echo running "%CMakePath%" --build %__IntermediatesDir% --target %__CMakeTarget% --config %__BuildType% -- !__CmakeBuildToolArgs! + "%CMakePath%" --build %__IntermediatesDir% --target %__CMakeTarget% --config %__BuildType% -- !__CmakeBuildToolArgs! if not !errorlevel! == 0 ( set __exitCode=!errorlevel! diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 3f16c82..540cbc3 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -21,12 +21,8 @@ export PYTHON usage_list+=("-nopgooptimize: do not use profile guided optimizations.") usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.") usage_list+=("-skipcrossarchnative: Skip building cross-architecture native binaries.") -usage_list+=("-staticanalyzer: skip native image generation.") -usage_list+=("-skipjit: skip building jit.") -usage_list+=("-skipalljits: skip building crosstargetting jits.") -usage_list+=("-skipruntime: skip building runtime.") -usage_list+=("-skipiltools: skip building IL tools.") -usage_list+=("-paltests: build the pal tests.") +usage_list+=("-staticanalyzer: use scan_build static analyzer.") +usage_list+=("-component: Build individual components instead of the full project. Available options are 'jit', 'runtime', 'paltests', 'alljits', and 'iltools'. Can be specified multiple times.") setup_dirs_local() { @@ -100,7 +96,7 @@ build_cross_architecture_components() export __CMakeBinDir CROSSCOMPILE __CMakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CROSS_COMPONENTS_BUILD=1 $__CMakeArgs" - build_native "$__TargetOS" "$__CrossArch" "$__ProjectRoot" "$intermediatesForBuild" "$__CMakeArgs" "cross-architecture components" + build_native "$__TargetOS" "$__CrossArch" "$__ProjectRoot" "$intermediatesForBuild" "crosscomponents" "$__CMakeArgs" "cross-architecture components" CROSSCOMPILE=1 export CROSSCOMPILE @@ -126,24 +122,9 @@ handle_arguments_local() { __StaticAnalyzer=1 ;; - skipjit|-skipjit) - __BuildJit=0 - ;; - - skipalljits|-skipalljits) - __BuildAllJits=0 - ;; - - skipruntime|-skipruntime) - __BuildRuntime=0 - ;; - - skipiltools|-skipiltools) - __BuildILTools=0 - ;; - - paltests|-paltests) - __BuildPALTests=1 + component|-component) + __RequestedBuildComponents="$__RequestedBuildComponents $2" + __ShiftArgs=1 ;; *) __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" @@ -197,8 +178,7 @@ __UseNinja=0 __VerboseBuild=0 __ValidateCrossArg=1 __CMakeArgs="" -__BuildJit=1 -__BuildPALTests=0 +__RequestedBuildComponents="" __BuildAllJits=1 __BuildRuntime=1 __BuildILTools=1 @@ -254,17 +234,24 @@ restore_optdata # Build the coreclr (native) components. __CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize $__CMakeArgs" -__CMakeArgs="-DCLR_CMAKE_BUILD_SUBSET_JIT=$__BuildJit -DCLR_CMAKE_BUILD_SUBSET_ALLJITS=$__BuildAllJits -DCLR_CMAKE_BUILD_SUBSET_RUNTIME=$__BuildRuntime $__CMakeArgs -DCLR_CMAKE_BUILD_SUBSET_ILTOOLS=$__BuildILTools" -__CMakeArgs="-DCLR_CMAKE_BUILD_TESTS=$__BuildPALTests $__CMakeArgs" if [[ "$__SkipConfigure" == 0 && "$__CodeCoverage" == 1 ]]; then __CMakeArgs="-DCLR_CMAKE_ENABLE_CODE_COVERAGE=1 $__CMakeArgs" fi +__CMakeTarget="" +if [[ -n "$__RequestedBuildComponents" ]]; then + __CMakeTarget=" $__RequestedBuildComponents " + __CMakeTarget="${__CMakeTarget// paltests / paltests_install }" +fi +if [[ -z "$__CMakeTarget" ]]; then + __CMakeTarget="install" +fi + if [[ "$__SkipNative" == 1 ]]; then echo "Skipping CoreCLR component build." else - build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeArgs" "CoreCLR component" + build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeTarget" "$__CMakeArgs" "CoreCLR component" # Build cross-architecture components if [[ "$__SkipCrossArchNative" != 1 ]]; then diff --git a/src/coreclr/components.cmake b/src/coreclr/components.cmake new file mode 100644 index 0000000..3d630bf --- /dev/null +++ b/src/coreclr/components.cmake @@ -0,0 +1,21 @@ +# Define all the individually buildable components of the CoreCLR build and their respective targets +add_component(jit) +add_component(alljits) +add_component(runtime) +add_component(paltests paltests_install) +add_component(iltools) + +# Define coreclr_all as the fallback component and make every component depend on this component. +# iltools should be a minimal subset, so don't add a dependency on coreclr_misc +set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME coreclr_misc) +add_component(coreclr_misc) +add_dependencies(jit coreclr_misc) +add_dependencies(alljits coreclr_misc) +add_dependencies(runtime coreclr_misc) +add_dependencies(paltests_install coreclr_misc) + +# The runtime build requires the clrjit and iltools builds +add_dependencies(runtime jit iltools) + +# The cross-components build is separate, so we don't need to add a dependency on coreclr_misc +add_component(crosscomponents) diff --git a/src/coreclr/crosscomponents.cmake b/src/coreclr/crosscomponents.cmake index c665318..e8d5191 100644 --- a/src/coreclr/crosscomponents.cmake +++ b/src/coreclr/crosscomponents.cmake @@ -1,31 +1,39 @@ -add_definitions(-DCROSS_COMPILE) - -if(CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_I386)) - set(FEATURE_CROSSBITNESS 1) -endif(CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_I386)) +# Add targets to the crosscomponents subcomponent build if (CLR_CMAKE_HOST_OS STREQUAL CLR_CMAKE_TARGET_OS) - set (CLR_CROSS_COMPONENTS_LIST + install_clr (TARGETS clrjit jitinterface_${ARCH_HOST_NAME} + DESTINATIONS . + COMPONENT crosscomponents ) if(CLR_CMAKE_HOST_LINUX OR NOT FEATURE_CROSSBITNESS) - list (APPEND CLR_CROSS_COMPONENTS_LIST + install_clr (TARGETS crossgen + DESTINATIONS . + COMPONENT crosscomponents ) endif() if (CLR_CMAKE_TARGET_UNIX) - list (APPEND CLR_CROSS_COMPONENTS_LIST + install_clr (TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} + DESTINATIONS . + COMPONENT crosscomponents ) endif(CLR_CMAKE_TARGET_UNIX) endif() if(NOT CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_OSX AND NOT FEATURE_CROSSBITNESS) - list (APPEND CLR_CROSS_COMPONENTS_LIST + install_clr (TARGETS mscordaccore mscordbi + DESTINATIONS . + COMPONENT crosscomponents ) endif() + +if (CLR_CMAKE_TARGET_WIN32 AND NOT CLR_CMAKE_CROSS_ARCH) + add_dependencies(crosscomponents InjectResource GenClrDebugResource) +endif() diff --git a/src/coreclr/debug/createdump/CMakeLists.txt b/src/coreclr/debug/createdump/CMakeLists.txt index 2e55b9a..5e6eda6 100644 --- a/src/coreclr/debug/createdump/CMakeLists.txt +++ b/src/coreclr/debug/createdump/CMakeLists.txt @@ -19,7 +19,7 @@ if(CLR_CMAKE_HOST_WIN32) createdump.rc ) - _add_executable(createdump + add_executable_clr(createdump ${CREATEDUMP_SOURCES} ) @@ -60,13 +60,13 @@ else(CLR_CMAKE_HOST_WIN32) ) if(CLR_CMAKE_HOST_OSX) - _add_executable(createdump + add_executable_clr(createdump crashinfomac.cpp threadinfomac.cpp ${CREATEDUMP_SOURCES} ) else() - _add_executable(createdump + add_executable_clr(createdump crashinfounix.cpp threadinfounix.cpp ${CREATEDUMP_SOURCES} @@ -86,4 +86,4 @@ endif(CLR_CMAKE_HOST_OSX) endif(CLR_CMAKE_HOST_WIN32) -install_clr(TARGETS createdump ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS createdump DESTINATIONS . sharedFramework COMPONENT runtime) diff --git a/src/coreclr/debug/debug-pal/CMakeLists.txt b/src/coreclr/debug/debug-pal/CMakeLists.txt index 3dfff70..d2846f9 100644 --- a/src/coreclr/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/debug/debug-pal/CMakeLists.txt @@ -52,6 +52,6 @@ if(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_UNIX) -_add_library(debug-pal_obj OBJECT ${TWO_WAY_PIPE_SOURCES}) +add_library_clr(debug-pal_obj OBJECT ${TWO_WAY_PIPE_SOURCES}) add_library(debug-pal INTERFACE) target_sources(debug-pal INTERFACE $) diff --git a/src/coreclr/debug/runtimeinfo/CMakeLists.txt b/src/coreclr/debug/runtimeinfo/CMakeLists.txt index c4ad348..ea59ece 100644 --- a/src/coreclr/debug/runtimeinfo/CMakeLists.txt +++ b/src/coreclr/debug/runtimeinfo/CMakeLists.txt @@ -37,4 +37,4 @@ if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) endif() # publish runtimeinfo lib -_install(TARGETS runtimeinfo DESTINATION lib) +install_clr(TARGETS runtimeinfo DESTINATIONS lib COMPONENT runtime) diff --git a/src/coreclr/dlls/clretwrc/CMakeLists.txt b/src/coreclr/dlls/clretwrc/CMakeLists.txt index d2cb5cf..cc427ef 100644 --- a/src/coreclr/dlls/clretwrc/CMakeLists.txt +++ b/src/coreclr/dlls/clretwrc/CMakeLists.txt @@ -20,6 +20,6 @@ add_library_clr(clretwrc SHARED ) # add the install targets -install_clr(TARGETS clretwrc ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS clretwrc DESTINATIONS . sharedFramework COMPONENT runtime) add_dependencies(clretwrc eventing_headers) diff --git a/src/coreclr/dlls/dbgshim/CMakeLists.txt b/src/coreclr/dlls/dbgshim/CMakeLists.txt index 1092799..5f323b2 100644 --- a/src/coreclr/dlls/dbgshim/CMakeLists.txt +++ b/src/coreclr/dlls/dbgshim/CMakeLists.txt @@ -84,4 +84,4 @@ endif(CLR_CMAKE_HOST_WIN32) target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES}) # add the install targets -install_clr(TARGETS dbgshim ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS dbgshim DESTINATIONS . sharedFramework COMPONENT runtime) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 3ec2b96..327560a 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -98,7 +98,7 @@ endif(CLR_CMAKE_HOST_WIN32) # Create object library to enable creation of proper dependency of mscordaccore.exp on mscordac.obj and # mscordaccore on both the mscordaccore.exp and mscordac.obj. -_add_library(mscordacobj OBJECT mscordac.cpp) +add_library_clr(mscordacobj OBJECT mscordac.cpp) add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES} $) @@ -193,7 +193,7 @@ endif(CLR_CMAKE_HOST_UNIX) target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES}) # add the install targets -install_clr(TARGETS mscordaccore ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS mscordaccore DESTINATIONS . sharedFramework COMPONENT runtime) if(CLR_CMAKE_HOST_WIN32) set(LONG_NAME_HOST_ARCH ${CLR_CMAKE_HOST_ARCH}) @@ -210,5 +210,5 @@ if(CLR_CMAKE_HOST_WIN32) string(REGEX MATCH "#define VER_FILEVERSION[ \t]+[0-9]+(,[0-9]+)+" FILE_VERSION_LINE "${NATIVE_VERSION_HEADER}") string(REGEX MATCHALL "[0-9]+" FILE_VERSION_COMPONENTS "${FILE_VERSION_LINE}") list(JOIN FILE_VERSION_COMPONENTS "." FILE_VERSION) - install(FILES $ RENAME mscordaccore_${LONG_NAME_HOST_ARCH}_${LONG_NAME_TARGET_ARCH}_${FILE_VERSION}.dll DESTINATION sharedFramework) + install(FILES $ RENAME mscordaccore_${LONG_NAME_HOST_ARCH}_${LONG_NAME_TARGET_ARCH}_${FILE_VERSION}.dll DESTINATION sharedFramework COMPONENT runtime) endif() diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index f000748..cc4b566 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -120,4 +120,4 @@ elseif(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_WIN32) # add the install targets -install_clr(TARGETS mscordbi ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS mscordbi DESTINATIONS . sharedFramework COMPONENT runtime) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 09897cd..2df7852 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -219,6 +219,7 @@ if(CLR_CMAKE_TARGET_WIN32) if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) add_custom_target(inject_debug_resources_coreclr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp) + add_dependencies(runtime inject_debug_resources_coreclr) endif() add_custom_command( @@ -240,11 +241,12 @@ if(CLR_CMAKE_TARGET_WIN32) if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) add_custom_target(inject_debug_resources_singlefilehost ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp) + add_dependencies(runtime inject_debug_resources_singlefilehost) endif() endif(CLR_CMAKE_TARGET_WIN32) # add the install targets -install_clr(TARGETS coreclr ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime) # Enable profile guided optimization add_pgo(coreclr) diff --git a/src/coreclr/dlls/mscorrc/CMakeLists.txt b/src/coreclr/dlls/mscorrc/CMakeLists.txt index 040b12a..c6618f0 100644 --- a/src/coreclr/dlls/mscorrc/CMakeLists.txt +++ b/src/coreclr/dlls/mscorrc/CMakeLists.txt @@ -15,7 +15,7 @@ if(CLR_CMAKE_HOST_WIN32) include.rc ) - install_clr(TARGETS mscorrc ADDITIONAL_DESTINATIONS sharedFramework) + install_clr(TARGETS mscorrc DESTINATIONS . sharedFramework COMPONENT runtime) else() build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE) diff --git a/src/coreclr/gc/CMakeLists.txt b/src/coreclr/gc/CMakeLists.txt index 3ba1e88..a6c4073 100644 --- a/src/coreclr/gc/CMakeLists.txt +++ b/src/coreclr/gc/CMakeLists.txt @@ -110,7 +110,7 @@ convert_to_absolute_path(GC_SOURCES ${GC_SOURCES}) add_library_clr(clrgc SHARED ${GC_SOURCES}) add_dependencies(clrgc eventing_headers) target_link_libraries(clrgc ${GC_LINK_LIBRARIES}) -install_clr(TARGETS clrgc) +install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime) if(CLR_CMAKE_HOST_UNIX) # dprintf causes many warnings (https://github.com/dotnet/runtime/issues/8737) diff --git a/src/coreclr/gc/sample/CMakeLists.txt b/src/coreclr/gc/sample/CMakeLists.txt index 8dbdca3..cf8c169 100644 --- a/src/coreclr/gc/sample/CMakeLists.txt +++ b/src/coreclr/gc/sample/CMakeLists.txt @@ -58,7 +58,7 @@ else() ../gcenv.unix.cpp) endif() -_add_executable(gcsample +add_executable_clr(gcsample ${SOURCES} ) diff --git a/src/coreclr/gcinfo/CMakeLists.txt b/src/coreclr/gcinfo/CMakeLists.txt index abdcd53..70b0f73 100644 --- a/src/coreclr/gcinfo/CMakeLists.txt +++ b/src/coreclr/gcinfo/CMakeLists.txt @@ -39,7 +39,7 @@ add_library_clr(gcinfo_crossgen set_target_properties(gcinfo_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) -_install (FILES gcinfoencoder.cpp +install (FILES gcinfoencoder.cpp DESTINATION gcinfo) function(create_gcinfo_lib) @@ -71,23 +71,14 @@ else() set(TARGET_OS_NAME win) endif() -if (CLR_CMAKE_BUILD_SUBSET_ALLJITS AND NOT CLR_CROSS_COMPONENTS_BUILD) - if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) - create_gcinfo_lib(TARGET gcinfo_unix_arm64 OS unix ARCH arm64) - create_gcinfo_lib(TARGET gcinfo_unix_x64 OS unix ARCH x64) - create_gcinfo_lib(TARGET gcinfo_win_arm64 OS win ARCH arm64) - create_gcinfo_lib(TARGET gcinfo_win_x64 OS win ARCH x64) - endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) - - create_gcinfo_lib(TARGET gcinfo_unix_armel OS unix ARCH armel) - create_gcinfo_lib(TARGET gcinfo_unix_arm OS unix ARCH arm) - create_gcinfo_lib(TARGET gcinfo_win_arm OS win ARCH arm) - create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86) -else() - create_gcinfo_lib(TARGET gcinfo_${TARGET_OS_NAME}_${ARCH_TARGET_NAME} OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME}) - - if (CLR_CMAKE_HOST_ARCH_I386 AND NOT ((TARGET_OS_NAME STREQUAL unix) AND (ARCH_TARGET_NAME STREQUAL "armel"))) - # On x86, build gcinfo for RyuJIT/ARM32 cross-compiling altjit for ARM_SOFTFP (armel). - create_gcinfo_lib(TARGET gcinfo_unix_armel OS unix ARCH armel) - endif() -endif (CLR_CMAKE_BUILD_SUBSET_ALLJITS AND NOT CLR_CROSS_COMPONENTS_BUILD) +if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) + create_gcinfo_lib(TARGET gcinfo_unix_arm64 OS unix ARCH arm64) + create_gcinfo_lib(TARGET gcinfo_unix_x64 OS unix ARCH x64) + create_gcinfo_lib(TARGET gcinfo_win_arm64 OS win ARCH arm64) + create_gcinfo_lib(TARGET gcinfo_win_x64 OS win ARCH x64) +endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) + +create_gcinfo_lib(TARGET gcinfo_unix_armel OS unix ARCH armel) +create_gcinfo_lib(TARGET gcinfo_unix_arm OS unix ARCH arm) +create_gcinfo_lib(TARGET gcinfo_win_arm OS win ARCH arm) +create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index fc1745c..da54587 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -9,7 +9,7 @@ else(CLR_CMAKE_HOST_WIN32) include(configure.cmake) endif(CLR_CMAKE_HOST_WIN32) -_add_executable(corerun +add_executable_clr(corerun corerun.cpp native.rc ) @@ -32,4 +32,4 @@ else(CLR_CMAKE_HOST_WIN32) endif() endif(CLR_CMAKE_HOST_WIN32) -install_clr(TARGETS corerun) +install_clr(TARGETS corerun DESTINATIONS . COMPONENT runtime) diff --git a/src/coreclr/hosts/coreshim/CMakeLists.txt b/src/coreclr/hosts/coreshim/CMakeLists.txt index 51061e1..5c6a2fd 100644 --- a/src/coreclr/hosts/coreshim/CMakeLists.txt +++ b/src/coreclr/hosts/coreshim/CMakeLists.txt @@ -22,4 +22,4 @@ target_link_libraries(CoreShim ${STATIC_MT_VCRT_LIB} ) -install_clr(TARGETS CoreShim) +install_clr(TARGETS CoreShim DESTINATIONS . COMPONENT runtime) diff --git a/src/coreclr/ilasm/CMakeLists.txt b/src/coreclr/ilasm/CMakeLists.txt index 3d38555..c2747a8 100644 --- a/src/coreclr/ilasm/CMakeLists.txt +++ b/src/coreclr/ilasm/CMakeLists.txt @@ -65,7 +65,7 @@ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CL set(END_LIBRARY_GROUP -Wl,--end-group) endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) -_add_executable(ilasm +add_executable_clr(ilasm ${ILASM_SOURCES} ${ILASM_RESOURCES} ) @@ -126,4 +126,4 @@ else() ) endif(CLR_CMAKE_HOST_UNIX) -install_clr(TARGETS ilasm) +install_clr(TARGETS ilasm DESTINATIONS . COMPONENT iltools) diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt index fe0892f..f946f33 100644 --- a/src/coreclr/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/ildasm/exe/CMakeLists.txt @@ -58,7 +58,7 @@ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CL set(END_LIBRARY_GROUP -Wl,--end-group) endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) -_add_executable(ildasm +add_executable_clr(ildasm ${ILDASM_SOURCES} ${ILDASM_RESOURCES} ) @@ -115,4 +115,4 @@ else() ) endif(CLR_CMAKE_HOST_UNIX) -install_clr(TARGETS ildasm) +install_clr(TARGETS ildasm DESTINATIONS . COMPONENT iltools) diff --git a/src/coreclr/inc/CMakeLists.txt b/src/coreclr/inc/CMakeLists.txt index 456cdf9..535be85 100644 --- a/src/coreclr/inc/CMakeLists.txt +++ b/src/coreclr/inc/CMakeLists.txt @@ -58,13 +58,13 @@ if(FEATURE_JIT_PITCHING) endif(FEATURE_JIT_PITCHING) # Compile *_i.cpp to lib -_add_library(corguids_obj OBJECT ${CORGUIDS_SOURCES}) +add_library_clr(corguids_obj OBJECT ${CORGUIDS_SOURCES}) add_library(corguids INTERFACE) target_sources(corguids INTERFACE $) # Binplace the inc files for packaging later. -_install (FILES cfi.h +install (FILES cfi.h cor.h cordebuginfo.h coredistools.h diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 7401264..8d30df4 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -11,9 +11,8 @@ endif() function(create_standalone_jit) set(oneValueArgs TARGET OS ARCH) - set(multiValueArgs ADDITIONAL_DESTINATIONS) - set(options) - cmake_parse_arguments(TARGETDETAILS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set(multiValueArgs DESTINATIONS) + cmake_parse_arguments(TARGETDETAILS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(TARGETDETAILS_OS STREQUAL "unix_osx") if (NOT (TARGETDETAILS_ARCH STREQUAL "arm64")) @@ -36,10 +35,10 @@ function(create_standalone_jit) clr_unknown_arch() endif() - if (TARGETDETAILS_ADDITIONAL_DESTINATIONS STREQUAL "") + if (TARGETDETAILS_DESTINATIONS STREQUAL "") add_jit(${TARGETDETAILS_TARGET}) else() - add_jit(${TARGETDETAILS_TARGET} ADDITIONAL_DESTINATIONS "${TARGETDETAILS_ADDITIONAL_DESTINATIONS}") + add_jit(${TARGETDETAILS_TARGET} DESTINATIONS "${TARGETDETAILS_DESTINATIONS}") endif() set_target_definitions_to_custom_os_and_arch(${ARGN}) @@ -420,7 +419,7 @@ else() endif(CLR_CMAKE_HOST_UNIX) # Shared function for generating JIT -# optional arguments: ADDITIONAL_DESTINATIONS path +# optional arguments: DESTINATIONS path function(add_jit jitName) set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE) @@ -453,7 +452,7 @@ function(add_jit jitName) ) # add the install targets - install_clr(TARGETS ${jitName} ${ARGN}) + install_clr(TARGETS ${jitName} ${ARGN} COMPONENT alljits) endfunction() set(JIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -473,39 +472,37 @@ else() set(TARGET_OS_NAME win) endif() -create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME} ADDITIONAL_DESTINATIONS sharedFramework) +create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME} DESTINATIONS . sharedFramework) +install_clr(TARGETS clrjit DESTINATIONS . sharedFramework COMPONENT jit) # Enable profile guided optimization add_pgo(clrjit) -if (CLR_CMAKE_BUILD_SUBSET_ALLJITS AND NOT CLR_CROSS_COMPONENTS_BUILD) - if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) - create_standalone_jit(TARGET clrjit_unix_arm64_${ARCH_HOST_NAME} OS unix ARCH arm64) - create_standalone_jit(TARGET clrjit_unix_osx_arm64_${ARCH_HOST_NAME} OS unix_osx ARCH arm64) - create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix ARCH x64) - create_standalone_jit(TARGET clrjit_win_arm64_${ARCH_HOST_NAME} OS win ARCH arm64) - create_standalone_jit(TARGET clrjit_win_x64_${ARCH_HOST_NAME} OS win ARCH x64) - endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) - - create_standalone_jit(TARGET clrjit_unix_armel_${ARCH_HOST_NAME} OS unix ARCH armel) - create_standalone_jit(TARGET clrjit_unix_arm_${ARCH_HOST_NAME} OS unix ARCH arm) - target_compile_definitions(clrjit_unix_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI) - create_standalone_jit(TARGET clrjit_win_arm_${ARCH_HOST_NAME} OS win ARCH arm) - create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86) -else() - if (CLR_CMAKE_TARGET_UNIX) - create_standalone_jit(TARGET clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} OS unix ARCH ${ARCH_TARGET_NAME}) +if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) + create_standalone_jit(TARGET clrjit_unix_arm64_${ARCH_HOST_NAME} OS unix ARCH arm64 DESTINATIONS .) + create_standalone_jit(TARGET clrjit_unix_osx_arm64_${ARCH_HOST_NAME} OS unix_osx ARCH arm64 DESTINATIONS .) + create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix ARCH x64 DESTINATIONS .) + create_standalone_jit(TARGET clrjit_win_arm64_${ARCH_HOST_NAME} OS win ARCH arm64 DESTINATIONS .) + create_standalone_jit(TARGET clrjit_win_x64_${ARCH_HOST_NAME} OS win ARCH x64 DESTINATIONS .) +endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) + +create_standalone_jit(TARGET clrjit_unix_armel_${ARCH_HOST_NAME} OS unix ARCH armel DESTINATIONS .) +create_standalone_jit(TARGET clrjit_unix_arm_${ARCH_HOST_NAME} OS unix ARCH arm DESTINATIONS .) +target_compile_definitions(clrjit_unix_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI) +create_standalone_jit(TARGET clrjit_win_arm_${ARCH_HOST_NAME} OS win ARCH arm DESTINATIONS .) +create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .) + +if (CLR_CMAKE_TARGET_UNIX) + install_clr(TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit) if (ARCH_TARGET_NAME STREQUAL arm) target_compile_definitions(clrjit_unix_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI) - endif (ARCH_TARGET_NAME STREQUAL arm) - endif(CLR_CMAKE_TARGET_UNIX) -endif (CLR_CMAKE_BUILD_SUBSET_ALLJITS AND NOT CLR_CROSS_COMPONENTS_BUILD) - + endif (ARCH_TARGET_NAME STREQUAL arm) +endif() if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_PGO_INSTRUMENT) # Copy PGO dependency to target dir set(PGORT_DLL "pgort140.dll") find_path(PGORT_DIR ${PGORT_DLL} REQUIRED) - _install(FILES "${PGORT_DIR}/${PGORT_DLL}" DESTINATION ${CMAKE_INSTALL_PREFIX}) - _install(FILES "${PGORT_DIR}/${PGORT_DLL}" DESTINATION ${CMAKE_INSTALL_PREFIX}/sharedFramework) + install(FILES "${PGORT_DIR}/${PGORT_DLL}" DESTINATION ${CMAKE_INSTALL_PREFIX}) + install(FILES "${PGORT_DIR}/${PGORT_DLL}" DESTINATION ${CMAKE_INSTALL_PREFIX}/sharedFramework) endif () diff --git a/src/coreclr/nativeresources/CMakeLists.txt b/src/coreclr/nativeresources/CMakeLists.txt index ab3e538..6959ca2 100644 --- a/src/coreclr/nativeresources/CMakeLists.txt +++ b/src/coreclr/nativeresources/CMakeLists.txt @@ -5,4 +5,4 @@ add_library_clr(nativeresourcestring resourcestring.cpp ) -_install (TARGETS nativeresourcestring DESTINATION lib) +install_clr (TARGETS nativeresourcestring DESTINATIONS lib) diff --git a/src/coreclr/pal/CMakeLists.txt b/src/coreclr/pal/CMakeLists.txt index dec1191..4509e9f 100644 --- a/src/coreclr/pal/CMakeLists.txt +++ b/src/coreclr/pal/CMakeLists.txt @@ -10,8 +10,4 @@ add_compile_options(-fexceptions) add_definitions(-DUSE_STL) add_subdirectory(src) - -if(CLR_CMAKE_BUILD_TESTS) - add_subdirectory(tests) -endif(CLR_CMAKE_BUILD_TESTS) - +add_subdirectory(tests) diff --git a/src/coreclr/pal/prebuilt/inc/CMakeLists.txt b/src/coreclr/pal/prebuilt/inc/CMakeLists.txt index 79f8e54..7fc6cb8 100644 --- a/src/coreclr/pal/prebuilt/inc/CMakeLists.txt +++ b/src/coreclr/pal/prebuilt/inc/CMakeLists.txt @@ -1,4 +1,4 @@ project(COREPAL) -_install (FILES corerror.h corprof.h DESTINATION inc) +install (FILES corerror.h corprof.h DESTINATION inc) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index cde9320..0c2021d 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -345,4 +345,4 @@ if(FEATURE_EVENT_TRACE) endif(FEATURE_EVENT_TRACE) # Install the static PAL library for VS -_install (TARGETS coreclrpal DESTINATION lib) +install_clr (TARGETS coreclrpal DESTINATIONS lib) diff --git a/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt index 5c3a04d..8773cd7 100644 --- a/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt +++ b/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt @@ -52,10 +52,9 @@ add_library(eventprovider eventproviderhelpers.cpp ) -add_library(coreclrtraceptprovider +add_library_clr(coreclrtraceptprovider SHARED ${TRACEPOINT_PROVIDER_SOURCES} - ${VERSION_FILE_PATH} ) add_dependencies(eventprovider generated_eventing_headers) @@ -70,6 +69,8 @@ target_link_libraries(coreclrtraceptprovider set_target_properties(coreclrtraceptprovider PROPERTIES LINKER_LANGUAGE CXX) # Install the static eventprovider library -_install(TARGETS eventprovider DESTINATION lib) +install_clr(TARGETS eventprovider DESTINATIONS lib COMPONENT runtime) # Install the static coreclrtraceptprovider library -install_clr(TARGETS coreclrtraceptprovider ADDITIONAL_DESTINATIONS sharedFramework paltests) +install_clr(TARGETS coreclrtraceptprovider DESTINATIONS . sharedFramework COMPONENT runtime) +install(TARGETS coreclrtraceptprovider DESTINATION paltests COMPONENT paltests EXCLUDE_FROM_ALL) +add_dependencies(paltests_install coreclrtraceptprovider) diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index f59e6f4..f58757a 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -32,7 +32,8 @@ if(FEATURE_EVENT_TRACE) add_subdirectory(eventprovider) endif(FEATURE_EVENT_TRACE) -_add_executable(paltests +add_executable_clr(paltests + EXCLUDE_FROM_ALL paltests.cpp common/palsuite.cpp #composite/object_management/event/nonshared/event.cpp @@ -918,7 +919,6 @@ _add_executable(paltests threading/WaitForSingleObject/WFSOSemaphoreTest/WFSOSemaphoreTest.cpp threading/WaitForSingleObject/WFSOThreadTest/WFSOThreadTest.cpp threading/YieldProcessor/test1/test1.cpp - ) add_dependencies(paltests coreclrpal) @@ -927,5 +927,6 @@ target_link_libraries(paltests ${COMMON_TEST_LIBRARIES} ) -_install (TARGETS paltests DESTINATION paltests) -_install (PROGRAMS runpaltests.sh runpaltestshelix.sh DESTINATION paltests) +install (TARGETS paltests DESTINATION paltests COMPONENT paltests EXCLUDE_FROM_ALL) +add_dependencies(paltests_install paltests) +install (PROGRAMS runpaltests.sh runpaltestshelix.sh DESTINATION paltests COMPONENT paltests EXCLUDE_FROM_ALL) diff --git a/src/coreclr/pal/tests/palsuite/eventprovider/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/eventprovider/CMakeLists.txt index ccb40b0..fdf326e 100644 --- a/src/coreclr/pal/tests/palsuite/eventprovider/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/eventprovider/CMakeLists.txt @@ -20,7 +20,8 @@ if(TARGET_UNIX) include_directories(${COREPAL_SOURCE_DIR}/inc/rt) endif(TARGET_UNIX) -_add_executable(eventprovidertest +add_executable_clr(eventprovidertest + EXCLUDE_FROM_ALL ${SOURCES} ) set(EVENT_PROVIDER_DEPENDENCIES "") @@ -39,4 +40,5 @@ endif(FEATURE_EVENT_TRACE) target_link_libraries(eventprovidertest ${EVENT_PROVIDER_DEPENDENCIES} coreclrpal) add_dependencies(eventprovidertest eventing_headers) -_install (TARGETS eventprovidertest DESTINATION paltests/eventprovider) \ No newline at end of file +install (TARGETS eventprovidertest DESTINATION paltests/eventprovider COMPONENT paltests EXCLUDE_FROM_ALL) +add_dependencies(paltests_install eventprovidertest) diff --git a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt index aec809d..08de84f 100644 --- a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt @@ -23,7 +23,7 @@ if(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_UNIX) set(DLL1SOURCES dlltest1.cpp) -_add_library(paltest_pal_sxs_test1_dll1 SHARED ${DLL1SOURCES}) +add_library_clr(paltest_pal_sxs_test1_dll1 SHARED EXCLUDE_FROM_ALL ${DLL1SOURCES}) add_custom_target(dlltest1_exports DEPENDS ${EXPORTS_FILE1}) set_property(TARGET paltest_pal_sxs_test1_dll1 APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION1}) set_property(TARGET paltest_pal_sxs_test1_dll1 APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE1}) @@ -55,7 +55,7 @@ if(CLR_CMAKE_TARGET_OSX) endif(CLR_CMAKE_TARGET_OSX) set(DLL2SOURCES dlltest2.cpp) -_add_library(paltest_pal_sxs_test1_dll2 SHARED ${DLL2SOURCES}) +add_library_clr(paltest_pal_sxs_test1_dll2 SHARED EXCLUDE_FROM_ALL ${DLL2SOURCES}) add_custom_target(dlltest2_exports DEPENDS ${EXPORTS_FILE2}) set_property(TARGET paltest_pal_sxs_test1_dll2 APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION2}) set_property(TARGET paltest_pal_sxs_test1_dll2 APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE2}) @@ -72,7 +72,7 @@ target_link_libraries(paltest_pal_sxs_test1_dll2 set(TESTSOURCES exceptionsxs.cpp) -_add_executable(paltest_pal_sxs_test1 ${TESTSOURCES}) +add_executable_clr(paltest_pal_sxs_test1 EXCLUDE_FROM_ALL ${TESTSOURCES}) add_dependencies(paltest_pal_sxs_test1 paltest_pal_sxs_test1_dll1 @@ -84,6 +84,7 @@ target_link_libraries(paltest_pal_sxs_test1 paltest_pal_sxs_test1_dll2 ) -_install (TARGETS paltest_pal_sxs_test1 DESTINATION paltests/exception_handling/pal_sxs/test1) -_install (TARGETS paltest_pal_sxs_test1_dll1 DESTINATION paltests/exception_handling/pal_sxs/test1) -_install (TARGETS paltest_pal_sxs_test1_dll2 DESTINATION paltests/exception_handling/pal_sxs/test1) \ No newline at end of file +install (TARGETS paltest_pal_sxs_test1 DESTINATION paltests/exception_handling/pal_sxs/test1 COMPONENT paltests EXCLUDE_FROM_ALL) +install (TARGETS paltest_pal_sxs_test1_dll1 DESTINATION paltests/exception_handling/pal_sxs/test1 COMPONENT paltests EXCLUDE_FROM_ALL) +install (TARGETS paltest_pal_sxs_test1_dll2 DESTINATION paltests/exception_handling/pal_sxs/test1 COMPONENT paltests EXCLUDE_FROM_ALL) +add_dependencies(paltests_install paltest_pal_sxs_test1 paltest_pal_sxs_test1_dll1 paltest_pal_sxs_test1_dll2) diff --git a/src/coreclr/palrt/CMakeLists.txt b/src/coreclr/palrt/CMakeLists.txt index a4c6fdd..f3042f2 100644 --- a/src/coreclr/palrt/CMakeLists.txt +++ b/src/coreclr/palrt/CMakeLists.txt @@ -17,4 +17,4 @@ add_library_clr(palrt ) # Install the static PAL library for VS -_install (TARGETS palrt DESTINATION lib) +install_clr(TARGETS palrt DESTINATIONS lib) diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index eb29aa0..7eb627e 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -28,16 +28,19 @@ <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" /> <_CoreClrBuildArg Condition="'$(Ninja)' == 'true' and !$([MSBuild]::IsOsPlatform(Windows))" Include="-ninja" /> <_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" /> - <_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' != 'true'" Include="-skipruntime" /> - <_CoreClrBuildArg Condition="'$(ClrJitSubset)' != 'true'" Include="-skipjit" /> - <_CoreClrBuildArg Condition="'$(ClrILToolsSubset)' != 'true'" Include="-skipiltools" /> - <_CoreClrBuildArg Condition="'$(ClrPalTestsSubset)' == 'true'" Include="-paltests" /> - <_CoreClrBuildArg Condition="'$(ClrAllJitsSubset)' != 'true'" Include="-skipalljits" /> <_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" /> <_CoreClrBuildArg Condition="'$(NoPgoOptimize)' == 'true' or '$(PgoInstrument)' == 'true'" Include="-nopgooptimize" /> <_CoreClrBuildArg Condition="'$(OfficialBuildId)' != ''" Include="/p:OfficialBuildId=$(OfficialBuildId)" /> + + <_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' == 'true'" Include="-component runtime" /> + <_CoreClrBuildArg Condition="'$(ClrJitSubset)' == 'true'" Include="-component jit" /> + <_CoreClrBuildArg Condition="'$(ClrPalTestsSubset)' == 'true'" Include="-component paltests" /> + <_CoreClrBuildArg Condition="'$(ClrAllJitsSubset)' == 'true'" Include="-component alljits" /> + <_CoreClrBuildArg Condition="'$(ClrILToolsSubset)' == 'true'" Include="-component iltools" /> + + <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh diff --git a/src/coreclr/tools/CMakeLists.txt b/src/coreclr/tools/CMakeLists.txt index 350a100..e2e3083 100644 --- a/src/coreclr/tools/CMakeLists.txt +++ b/src/coreclr/tools/CMakeLists.txt @@ -3,7 +3,5 @@ if (CLR_CMAKE_TARGET_WIN32 AND NOT CLR_CMAKE_CROSS_ARCH) add_subdirectory(GenClrDebugResource) add_subdirectory(InjectResource) - if (CLR_CROSS_COMPONENTS_BUILD) - install(EXPORT dactabletools DESTINATION dactabletools) - endif() + install(EXPORT dactabletools DESTINATION dactabletools COMPONENT crosscomponents) endif() diff --git a/src/coreclr/tools/GenClrDebugResource/CMakeLists.txt b/src/coreclr/tools/GenClrDebugResource/CMakeLists.txt index 0db21fa..2ea56e1 100644 --- a/src/coreclr/tools/GenClrDebugResource/CMakeLists.txt +++ b/src/coreclr/tools/GenClrDebugResource/CMakeLists.txt @@ -6,4 +6,4 @@ target_link_libraries(GenClrDebugResource ${STATIC_MT_VCRT_LIB} ) -install(TARGETS GenClrDebugResource EXPORT dactabletools DESTINATION dactabletools) +install(TARGETS GenClrDebugResource EXPORT dactabletools DESTINATION dactabletools COMPONENT crosscomponents) diff --git a/src/coreclr/tools/InjectResource/CMakeLists.txt b/src/coreclr/tools/InjectResource/CMakeLists.txt index 0e987ae..51f2b19 100644 --- a/src/coreclr/tools/InjectResource/CMakeLists.txt +++ b/src/coreclr/tools/InjectResource/CMakeLists.txt @@ -9,4 +9,4 @@ target_link_libraries(InjectResource ${STATIC_MT_VCRT_LIB} ) -install(TARGETS InjectResource EXPORT dactabletools DESTINATION dactabletools) +install(TARGETS InjectResource EXPORT dactabletools DESTINATION dactabletools COMPONENT crosscomponents) diff --git a/src/coreclr/tools/aot/jitinterface/CMakeLists.txt b/src/coreclr/tools/aot/jitinterface/CMakeLists.txt index 9b7640e..0b1cdc3 100644 --- a/src/coreclr/tools/aot/jitinterface/CMakeLists.txt +++ b/src/coreclr/tools/aot/jitinterface/CMakeLists.txt @@ -17,4 +17,5 @@ add_library_clr(jitinterface_${ARCH_HOST_NAME} ${JITINTERFACE_RESOURCES} ) -install_clr(TARGETS jitinterface_${ARCH_HOST_NAME}) +install_clr(TARGETS jitinterface_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit) +install_clr(TARGETS jitinterface_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT alljits) diff --git a/src/coreclr/tools/crossgen/CMakeLists.txt b/src/coreclr/tools/crossgen/CMakeLists.txt index eff97b0..6b998eb 100644 --- a/src/coreclr/tools/crossgen/CMakeLists.txt +++ b/src/coreclr/tools/crossgen/CMakeLists.txt @@ -80,4 +80,4 @@ add_subdirectory(../../zap ../../zap) add_subdirectory(../../vm/crossgen ../../vm/crossgen) # add the install targets -install_clr(TARGETS crossgen ADDITIONAL_DESTINATIONS sharedFramework) +install_clr(TARGETS crossgen DESTINATIONS . sharedFramework COMPONENT runtime) diff --git a/src/coreclr/vm/CMakeLists.txt b/src/coreclr/vm/CMakeLists.txt index 5bd3262..0e1c251 100644 --- a/src/coreclr/vm/CMakeLists.txt +++ b/src/coreclr/vm/CMakeLists.txt @@ -909,14 +909,12 @@ convert_to_absolute_path(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM}) convert_to_absolute_path(VM_SOURCES_DAC ${VM_SOURCES_DAC}) convert_to_absolute_path(VM_SOURCES_WKS_SPECIAL ${VM_SOURCES_WKS_SPECIAL}) -if (CLR_CMAKE_BUILD_SUBSET_RUNTIME) - add_library_clr(cee_dac ${VM_SOURCES_DAC}) - add_dependencies(cee_dac eventing_headers) - set_target_properties(cee_dac PROPERTIES DAC_COMPONENT TRUE) - target_precompile_headers(cee_dac PRIVATE [["common.h"]]) - - add_subdirectory(wks) -endif(CLR_CMAKE_BUILD_SUBSET_RUNTIME) +add_library_clr(cee_dac ${VM_SOURCES_DAC}) +add_dependencies(cee_dac eventing_headers) +set_target_properties(cee_dac PROPERTIES DAC_COMPONENT TRUE) +target_precompile_headers(cee_dac PRIVATE [["common.h"]]) + +add_subdirectory(wks) if(FEATURE_PERFTRACING) add_subdirectory(eventing) diff --git a/src/coreclr/vm/eventing/CMakeLists.txt b/src/coreclr/vm/eventing/CMakeLists.txt index 8143647..1e27a3c 100644 --- a/src/coreclr/vm/eventing/CMakeLists.txt +++ b/src/coreclr/vm/eventing/CMakeLists.txt @@ -37,10 +37,7 @@ set_source_files_properties(${EventingHeaders} PROPERTIES GENERATED TRUE) add_custom_target(eventing_headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/eventing_headers.timestamp) add_dependencies(eventing_headers eventprovider) -# When we are not building the JIT, we only build the headers here -if(CLR_CMAKE_BUILD_SUBSET_JIT) - add_subdirectory(eventpipe) -endif() +add_subdirectory(eventpipe) if(CLR_CMAKE_HOST_WIN32) add_subdirectory(EtwProvider) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt index 797ae3c..148197a 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt @@ -103,7 +103,7 @@ if(CLR_CMAKE_TARGET_UNIX) set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) endif() -install (TARGETS System.Globalization.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.Globalization.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) if (GEN_SHARED_LIB) diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt index e45d404..f68e1ac 100644 --- a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt @@ -100,4 +100,4 @@ add_library(System.IO.Compression.Native-Static set_target_properties(System.IO.Compression.Native-Static PROPERTIES OUTPUT_NAME System.IO.Compression.Native CLEAN_DIRECT_OUTPUT 1) -install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt index ede4480..b78dce7 100644 --- a/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt @@ -21,4 +21,4 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.IO.Ports.Native PROGRAMS .) endif() -install (TARGETS System.IO.Ports.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.IO.Ports.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/Unix/System.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Native/CMakeLists.txt index 2ff29da..12245f8 100644 --- a/src/libraries/Native/Unix/System.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Native/CMakeLists.txt @@ -92,4 +92,4 @@ add_library(System.Native-Static set_target_properties(System.Native-Static PROPERTIES OUTPUT_NAME System.Native CLEAN_DIRECT_OUTPUT 1) -install (TARGETS System.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt index 3c03fa1..6fbe18f 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt @@ -49,4 +49,4 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Net.Security.Native PROGRAMS .) endif() -install (TARGETS System.Net.Security.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.Net.Security.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt index a222753..56d07f7 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt @@ -65,4 +65,4 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Security.Cryptography.Native.Apple PROGRAMS .) endif() -install (TARGETS System.Security.Cryptography.Native.Apple-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.Security.Cryptography.Native.Apple-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index 83b9ae5..62668e7 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -119,4 +119,4 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Security.Cryptography.Native.OpenSsl PROGRAMS .) endif() -install (TARGETS System.Security.Cryptography.Native.OpenSsl-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.Security.Cryptography.Native.OpenSsl-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index 77b6d97..b9b6c82 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -9,15 +9,11 @@ SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/O2 /Zi") SET (CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256") # Configuration of our libray specs and our directories -SET (CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) SET (CMAKE_INCLUDE_CURRENT_DIR ON) SET (CMAKE_SHARED_LIBRARY_PREFIX "") set(__SharedLinkArgs) set(__LinkArgs) -if ($ENV{__LinkArgs}) - SET (__LinkArgs $ENV{__LinkArgs}) -endif() # Force an out of source build if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") @@ -61,7 +57,7 @@ add_compile_options(/Zl) # enable debugging information add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640) add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files. -if ($ENV{__BuildArch} STREQUAL "x86") +if (${CLR_CMAKE_HOST_ARCH} STREQUAL "x86") add_compile_options(/Gz) endif () @@ -113,7 +109,7 @@ endif() # Debug build specific flags list(INSERT __SharedLinkArgs 0 $<$,$>:/NOVCFEATURE>) -if ($ENV{__BuildArch} STREQUAL "x86_64" OR $ENV{__BuildArch} STREQUAL "amd64") +if (${CLR_CMAKE_HOST_ARCH} STREQUAL "x86_64" OR ${CLR_CMAKE_HOST_ARCH} STREQUAL "amd64") add_definitions(-DTARGET_64BIT=1) endif () diff --git a/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt b/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt index e161657..0ca238d 100644 --- a/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt +++ b/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt @@ -10,7 +10,7 @@ if (GEN_SHARED_LIB) include (GenerateExportHeader) endif() -if($ENV{__BuildArch} STREQUAL x86 OR $ENV{__BuildArch} STREQUAL x64) +if(${CLR_CMAKE_HOST_ARCH} STREQUAL x86 OR ${CLR_CMAKE_HOST_ARCH} STREQUAL x64) set(NATIVECOMPRESSION_SOURCES zlib-intel/adler32.c zlib-intel/compress.c @@ -122,4 +122,4 @@ if (GEN_SHARED_LIB) install (FILES $ DESTINATION .) endif() -install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) +install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index 15389a5..b6c1984 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -13,7 +13,6 @@ set __BuildArch=x64 set __BuildTarget="build" set __TargetOS=windows set CMAKE_BUILD_TYPE=Debug -set "__LinkArgs= " set "__LinkLibraries= " set __Ninja=1 diff --git a/src/libraries/Native/build-native.sh b/src/libraries/Native/build-native.sh index 19dedb2..55d56a7 100755 --- a/src/libraries/Native/build-native.sh +++ b/src/libraries/Native/build-native.sh @@ -137,7 +137,7 @@ elif [[ "$__TargetOS" == iOS ]]; then fi elif [[ "$__TargetOS" == tvOSSimulator ]]; then __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS $__CMakeArgs" - # set default tvOS device deployment target + # set default tvOS device deployment target # keep in sync with tvOSVersionMin in src/mono/Directory.Build.props __CMakeArgs="-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 $__CMakeArgs" if [[ "$__BuildArch" == x64 ]]; then @@ -178,4 +178,4 @@ setup_dirs check_prereqs # Build the corefx native components. -build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component" +build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__IntermediatesDir" "install" "$__CMakeArgs" "native libraries component" diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 9a0c236..5f8c0db 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -93,6 +93,9 @@ include(${PROJECT_SOURCE_DIR}/../../../eng/native/configureplatform.cmake) include(${PROJECT_SOURCE_DIR}/../../../eng/native/configurecompiler.cmake) if (CLR_CMAKE_HOST_UNIX) + # Add custom targets that the pal build expects. + add_component(${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) + add_component(paltests_install) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index d7e129c..5e3aaf3 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -84,6 +84,10 @@ else() set_exports_linker_option(${EXPORTS_FILE}) endif() +if (CLR_SINGLE_FILE_HOST_ONLY) + set(ADDITIONAL_INSTALL_ARGUMENTS COMPONENT runtime) +endif() + include(../../exe.cmake) include(configure.cmake) diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index 0c7d512..3aa6820 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -106,7 +106,7 @@ setup_dirs check_prereqs # Build the installer native components. -build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__IntermediatesDir" "$__CMakeArgs" "installer component" +build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__IntermediatesDir" "install" "$__CMakeArgs" "installer component" if [[ "$__RuntimeFlavor" != "Mono" ]]; then echo Copying "$__CoreClrArtifacts/corehost/." to "$__CMakeBinDir/corehost" diff --git a/src/native/corehost/exe.cmake b/src/native/corehost/exe.cmake index c607421..f49ed59 100644 --- a/src/native/corehost/exe.cmake +++ b/src/native/corehost/exe.cmake @@ -26,6 +26,6 @@ if(NOT CLR_CMAKE_TARGET_WIN32) disable_pax_mprotect(${DOTNET_PROJECT_NAME}) endif() -install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost) +install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost ${ADDITIONAL_INSTALL_ARGUMENTS}) set_common_libs("exe") diff --git a/src/native/corehost/setup.cmake b/src/native/corehost/setup.cmake index 5dd2c7e..d2e4715 100644 --- a/src/native/corehost/setup.cmake +++ b/src/native/corehost/setup.cmake @@ -1,7 +1,7 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -if(CLR_CMAKE_BUILD_SUBSET_RUNTIME) +if(CLR_SINGLE_FILE_HOST_ONLY) # CLR partition builds only the single file host where hosting components are all statically linked. # the versioning information is irrelevant and may only come up in tracing. # so we will use "static" diff --git a/src/tests/build.sh b/src/tests/build.sh index 2539c80..4531a07 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -279,7 +279,7 @@ build_Tests() fi if [[ "$__SkipNative" != 1 && "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" ]]; then - build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__NativeTestIntermediatesDir" "CoreCLR test component" + build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then echo "${__ErrMsgPrefix}${__MsgPrefix}Error: native test build failed. Refer to the build log files for details (above)" -- 2.7.4