Skip to content

Commit

Permalink
Remove the crosscomponents.cmake logic and use various components tha…
Browse files Browse the repository at this point in the history
…t already exist to build "run on host" binaries (#111677)
  • Loading branch information
jkoritzinsky authored Jan 23, 2025
1 parent f196875 commit d917005
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 98 deletions.
18 changes: 13 additions & 5 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,24 @@
<!--
Build the CoreCLR cross tools when we're doing a cross build and either we're building any CoreCLR native tools for platforms CoreCLR fully supports or when someone explicitly requests them.
The cross tools are used as part of the build process with the downloaded build tools, so we need to build them for the host architecture and build them as unsanitized binaries.
Additionally, in a vertical orchestrated build, we need to produce an ilasm and ildasm for use by upstack repositories.
However, these repositories only build on Windows, so we can limit this to only execute on Windows to avoid additional infrastructure work when not necessary.
-->
<PropertyGroup>
<_BuildAnyCrossArch Condition="'$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(EnableNativeSanitizers)' != ''">true</_BuildAnyCrossArch>
<_BuildCrossComponents Condition="$(_subset.Contains('+clr.crossarchtools+'))">true</_BuildCrossComponents>
<_BuildCrossComponents Condition="'$(ClrRuntimeBuildSubsets)' != '' and ('$(PrimaryRuntimeFlavor)' == 'CoreCLR' or '$(TargetsMobile)' == 'true')">true</_BuildCrossComponents>
<_CrossBitwidthBuild Condition="'$(BuildArchitecture)' == 'x64' and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'arm')">true</_CrossBitwidthBuild>
<_BuildCrossDebugComponents Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWindows)' == 'true' and '$(_CrossBitwidthBuild)' != 'true'">true</_BuildCrossDebugComponents>
</PropertyGroup>

<ItemGroup>
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true'" Include="ClrCrossComponentsSubset=true" />
<!-- When building cross components, always build the JITs. We will need them for running crossgen2 and ILC in the build. -->
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true'" Include="ClrAllJitsSubset=true" />
<!-- When targeting Windows, we need to build a copy of the diagnostic libraries that can run on the host to enable remote debugging of a local build. -->
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWindows)' == 'true'" Include="ClrDebugSubset=true" />
<!--
In a vertical orchestrated build, we need to produce an ilasm and ildasm for use by upstack repositories.
However, these repositories only build on Windows, so we can limit this to only execute on Windows to avoid additional infrastructure work when not necessary.
-->
<_CrossToolSubset Condition="'$(BuildHostILTools)' == 'true'" Include="ClrILToolsSubset=true" />
</ItemGroup>

Expand All @@ -331,6 +338,7 @@
PgoInstrument=false;
NoPgoOptimize=true;
CrossBuild=false;
BuildSubdirectory=$(BuildArchitecture);
CMakeArgs=$(CMakeArgs) -DCLR_CROSS_COMPONENTS_BUILD=1"
UndefineProperties="EnableNativeSanitizers"
Category="clr" />
Expand Down Expand Up @@ -366,7 +374,7 @@
<ProjectToBuild
Include="$(CoreClrProjectRoot)runtime.proj"
AdditionalProperties="%(AdditionalProperties);
ClrCrossComponentsSubset=true;
ClrDebugSubset=true;
HostArchitecture=$(CrossDacHostArch);
PgoInstrument=false;
NoPgoOptimize=true;
Expand All @@ -378,7 +386,7 @@
<ProjectToBuild
Include="$(CoreClrProjectRoot)runtime.proj"
AdditionalProperties="%(AdditionalProperties);
ClrCrossComponentsSubset=true;
ClrDebugSubset=true;
HostArchitecture=$(CrossDacHostArch);
PgoInstrument=false;
NoPgoOptimize=true;
Expand Down
1 change: 0 additions & 1 deletion eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ while :; do
hostarch|-hostarch)
if [[ -n "$2" ]]; then
__HostArch="$2"
__ExplicitHostArch=1
shift
else
echo "ERROR: 'hostarch' requires a non-empty option argument"
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,3 @@ if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_H
add_subdirectory(hosts)
endif(CLR_CMAKE_HOST_WIN32)
endif(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)

#----------------------------------------------------
# Cross target Component install configuration
#----------------------------------------------------
if(CLR_CROSS_COMPONENTS_BUILD)
include(crosscomponents.cmake)
endif(CLR_CROSS_COMPONENTS_BUILD)

11 changes: 1 addition & 10 deletions src/coreclr/build-runtime.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ set __CMakeArgs=
set __Ninja=1
set __RequestedBuildComponents=
set __OutputRid=
set __ExplicitHostArch=
set __SubDir=

:Arg_Loop
Expand Down Expand Up @@ -128,7 +127,7 @@ if [!__PassThroughArgs!]==[] (
set "__PassThroughArgs=%__PassThroughArgs% %1"
)

if /i "%1" == "-hostarch" (set __HostArch=%2&set __ExplicitHostArch=1&shift&shift&goto Arg_Loop)
if /i "%1" == "-hostarch" (set __HostArch=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "-os" (set __TargetOS=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "-outputrid" (set __OutputRid=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "-subdir" (set __SubDir=%2&shift&shift&goto Arg_Loop)
Expand Down Expand Up @@ -221,11 +220,6 @@ set "__ArtifactsIntermediatesDir=%__RepoRootDir%\artifacts\obj\coreclr\"
if "%__Ninja%"=="0" (set "__IntermediatesDir=%__IntermediatesDir%\ide")
set "__PackagesBinDir=%__BinDir%\.nuget"

if "%__ExplicitHostArch%" == "1" (
set __BinDir=%__BinDir%\%__HostArch%
set __IntermediatesDir=%__IntermediatesDir%\%__HostArch%
)

if NOT "%__SubDir%"=="" (
set __BinDir=%__BinDir%\%__SubDir%
set __IntermediatesDir=%__IntermediatesDir%\%__SubDir%
Expand Down Expand Up @@ -326,9 +320,6 @@ for /f "delims=" %%a in ("-%__RequestedBuildComponents%-") do (
if not "!string:-spmi-=!"=="!string!" (
set __CMakeTarget=!__CMakeTarget! spmi
)
if not "!string:-crosscomponents-=!"=="!string!" (
set __CMakeTarget=!__CMakeTarget! crosscomponents
)
if not "!string:-debug-=!"=="!string!" (
set __CMakeTarget=!__CMakeTarget! debug
)
Expand Down
7 changes: 1 addition & 6 deletions src/coreclr/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ handle_arguments_local() {
__RequestedBuildComponents="$__RequestedBuildComponents $2"
__ShiftArgs=1
;;

subdir|-subdir)
__SubDir="$2"
__ShiftArgs=1
Expand Down Expand Up @@ -123,11 +123,6 @@ __IntermediatesDir="$__ArtifactsIntermediatesDir/$__ConfigTriplet"

export __IntermediatesDir __ArtifactsIntermediatesDir

if [[ "$__ExplicitHostArch" == 1 ]]; then
__IntermediatesDir="$__IntermediatesDir/$__HostArch"
__BinDir="$__BinDir/$__HostArch"
fi

if [[ -n "$__SubDir" ]]; then
__IntermediatesDir="$__IntermediatesDir/$__SubDir"
__BinDir="$__BinDir/$__SubDir"
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/components.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ add_component(debug)
# iltools and paltests should be minimal subsets, 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)

# The runtime build requires the clrjit and iltools builds
Expand All @@ -24,6 +22,3 @@ add_dependencies(runtime jit iltools)
add_dependencies(runtime debug)

add_dependencies(runtime hosts)

# The cross-components build is separate, so we don't need to add a dependency on coreclr_misc
add_component(crosscomponents)
39 changes: 0 additions & 39 deletions src/coreclr/crosscomponents.cmake

This file was deleted.

8 changes: 2 additions & 6 deletions src/coreclr/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,6 @@ if(CLR_CMAKE_HOST_WIN32)
# debuggers and the runtime. This long form supports postmortem cross-architecture diagnostic scenarios.
# It doesn't make sense to complicate install_clr for this purpose, so keep it self-contained here.
set(LONG_NAME_BASE mscordaccore_${LONG_NAME_HOST_ARCH}_${LONG_NAME_TARGET_ARCH}_${FILE_VERSION})
install(PROGRAMS $<TARGET_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.dll DESTINATION sharedFramework COMPONENT runtime)
install(FILES $<TARGET_PDB_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.pdb DESTINATION sharedFramework/PDB COMPONENT runtime)
if (NOT FEATURE_CROSSBITNESS)
install(PROGRAMS $<TARGET_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.dll DESTINATION sharedFramework COMPONENT crosscomponents)
install(FILES $<TARGET_PDB_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.pdb DESTINATION sharedFramework/PDB COMPONENT crosscomponents)
endif()
install(PROGRAMS $<TARGET_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.dll DESTINATION sharedFramework COMPONENT debug)
install(FILES $<TARGET_PDB_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.pdb DESTINATION sharedFramework/PDB COMPONENT debug)
endif()
36 changes: 18 additions & 18 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ endif()
function(create_standalone_jit)

set(oneValueArgs TARGET OS ARCH)
set(multiValueArgs DESTINATIONS)
cmake_parse_arguments(TARGETDETAILS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
cmake_parse_arguments(TARGETDETAILS "" "${oneValueArgs}" "" ${ARGN})

if(TARGETDETAILS_OS STREQUAL "unix_osx" OR TARGETDETAILS_OS STREQUAL "unix_anyos")
set(JIT_ARCH_LINK_LIBRARIES gcinfo_unix_${TARGETDETAILS_ARCH})
Expand Down Expand Up @@ -58,11 +57,7 @@ function(create_standalone_jit)
clr_unknown_arch()
endif()

if (TARGETDETAILS_DESTINATIONS STREQUAL "")
add_jit(${TARGETDETAILS_TARGET})
else()
add_jit(${TARGETDETAILS_TARGET} DESTINATIONS "${TARGETDETAILS_DESTINATIONS}")
endif()
add_jit(${TARGETDETAILS_TARGET})

set_target_definitions_to_custom_os_and_arch(${ARGN})
set_target_properties(${TARGETDETAILS_TARGET} PROPERTIES IGNORE_FEATURE_MERGE_JIT_AND_ENGINE TRUE)
Expand Down Expand Up @@ -564,7 +559,6 @@ else()
endif(CLR_CMAKE_HOST_UNIX)

# Shared function for generating JIT
# optional arguments: DESTINATIONS path
function(add_jit jitName)

set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE)
Expand Down Expand Up @@ -616,7 +610,7 @@ function(add_jit jitName)
endif()

# add the install targets
install_clr(TARGETS ${jitName} ${ARGN} COMPONENT alljits)
install_clr(TARGETS ${jitName} DESTINATIONS . COMPONENT alljits)
endfunction()

set(JIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand All @@ -632,32 +626,38 @@ else()
set(TARGET_OS_NAME win)
endif()

create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME} DESTINATIONS . sharedFramework)
create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME})
install_clr(TARGETS clrjit DESTINATIONS . sharedFramework COMPONENT jit)

if (NOT CLR_CROSS_COMPONENTS_BUILD)
# Install the clrjit into the sharedframework dir only when we're not doing a cross-components build.
# We never want to ship the cross-component JIT (it would never be used).
install_clr(TARGETS clrjit DESTINATIONS sharedFramework COMPONENT alljits)
endif()

# Enable profile guided optimization
add_pgo(clrjit)

if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
create_standalone_jit(TARGET clrjit_universal_arm64_${ARCH_HOST_NAME} OS universal ARCH arm64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix_anyos ARCH x64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_win_x64_${ARCH_HOST_NAME} OS win ARCH x64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_universal_arm64_${ARCH_HOST_NAME} OS universal ARCH arm64)
create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix_anyos ARCH x64)
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)

if (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
create_standalone_jit(TARGET clrjit_unix_loongarch64_${ARCH_HOST_NAME} OS unix ARCH loongarch64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_unix_loongarch64_${ARCH_HOST_NAME} OS unix ARCH loongarch64)
endif (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)

if (CLR_CMAKE_TARGET_ARCH_RISCV64)
create_standalone_jit(TARGET clrjit_unix_riscv64_${ARCH_HOST_NAME} OS unix ARCH riscv64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_unix_riscv64_${ARCH_HOST_NAME} OS unix ARCH riscv64)
else()
create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm DESTINATIONS .)
create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm)
target_compile_definitions(clrjit_universal_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86)
endif (CLR_CMAKE_TARGET_ARCH_RISCV64)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_standalone_jit(TARGET clrjit_unix_x86_${ARCH_HOST_NAME} OS unix ARCH x86 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_unix_x86_${ARCH_HOST_NAME} OS unix ARCH x86)
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)

if (CLR_CMAKE_TARGET_UNIX)
Expand Down

0 comments on commit d917005

Please sign in to comment.