Skip to content

Commit d917005

Browse files
authored
Remove the crosscomponents.cmake logic and use various components that already exist to build "run on host" binaries (#111677)
1 parent f196875 commit d917005

File tree

9 files changed

+35
-98
lines changed

9 files changed

+35
-98
lines changed

eng/Subsets.props

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,24 @@
308308
<!--
309309
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.
310310
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.
311-
Additionally, in a vertical orchestrated build, we need to produce an ilasm and ildasm for use by upstack repositories.
312-
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.
313311
-->
314312
<PropertyGroup>
315313
<_BuildAnyCrossArch Condition="'$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(EnableNativeSanitizers)' != ''">true</_BuildAnyCrossArch>
316314
<_BuildCrossComponents Condition="$(_subset.Contains('+clr.crossarchtools+'))">true</_BuildCrossComponents>
317315
<_BuildCrossComponents Condition="'$(ClrRuntimeBuildSubsets)' != '' and ('$(PrimaryRuntimeFlavor)' == 'CoreCLR' or '$(TargetsMobile)' == 'true')">true</_BuildCrossComponents>
316+
<_CrossBitwidthBuild Condition="'$(BuildArchitecture)' == 'x64' and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'arm')">true</_CrossBitwidthBuild>
317+
<_BuildCrossDebugComponents Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWindows)' == 'true' and '$(_CrossBitwidthBuild)' != 'true'">true</_BuildCrossDebugComponents>
318318
</PropertyGroup>
319319

320320
<ItemGroup>
321-
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true'" Include="ClrCrossComponentsSubset=true" />
321+
<!-- When building cross components, always build the JITs. We will need them for running crossgen2 and ILC in the build. -->
322+
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true'" Include="ClrAllJitsSubset=true" />
323+
<!-- 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. -->
324+
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWindows)' == 'true'" Include="ClrDebugSubset=true" />
325+
<!--
326+
In a vertical orchestrated build, we need to produce an ilasm and ildasm for use by upstack repositories.
327+
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.
328+
-->
322329
<_CrossToolSubset Condition="'$(BuildHostILTools)' == 'true'" Include="ClrILToolsSubset=true" />
323330
</ItemGroup>
324331

@@ -331,6 +338,7 @@
331338
PgoInstrument=false;
332339
NoPgoOptimize=true;
333340
CrossBuild=false;
341+
BuildSubdirectory=$(BuildArchitecture);
334342
CMakeArgs=$(CMakeArgs) -DCLR_CROSS_COMPONENTS_BUILD=1"
335343
UndefineProperties="EnableNativeSanitizers"
336344
Category="clr" />
@@ -366,7 +374,7 @@
366374
<ProjectToBuild
367375
Include="$(CoreClrProjectRoot)runtime.proj"
368376
AdditionalProperties="%(AdditionalProperties);
369-
ClrCrossComponentsSubset=true;
377+
ClrDebugSubset=true;
370378
HostArchitecture=$(CrossDacHostArch);
371379
PgoInstrument=false;
372380
NoPgoOptimize=true;
@@ -378,7 +386,7 @@
378386
<ProjectToBuild
379387
Include="$(CoreClrProjectRoot)runtime.proj"
380388
AdditionalProperties="%(AdditionalProperties);
381-
ClrCrossComponentsSubset=true;
389+
ClrDebugSubset=true;
382390
HostArchitecture=$(CrossDacHostArch);
383391
PgoInstrument=false;
384392
NoPgoOptimize=true;

eng/native/build-commons.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ while :; do
485485
hostarch|-hostarch)
486486
if [[ -n "$2" ]]; then
487487
__HostArch="$2"
488-
__ExplicitHostArch=1
489488
shift
490489
else
491490
echo "ERROR: 'hostarch' requires a non-empty option argument"

src/coreclr/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,3 @@ if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_H
265265
add_subdirectory(hosts)
266266
endif(CLR_CMAKE_HOST_WIN32)
267267
endif(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
268-
269-
#----------------------------------------------------
270-
# Cross target Component install configuration
271-
#----------------------------------------------------
272-
if(CLR_CROSS_COMPONENTS_BUILD)
273-
include(crosscomponents.cmake)
274-
endif(CLR_CROSS_COMPONENTS_BUILD)
275-

src/coreclr/build-runtime.cmd

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ set __CMakeArgs=
7070
set __Ninja=1
7171
set __RequestedBuildComponents=
7272
set __OutputRid=
73-
set __ExplicitHostArch=
7473
set __SubDir=
7574

7675
:Arg_Loop
@@ -128,7 +127,7 @@ if [!__PassThroughArgs!]==[] (
128127
set "__PassThroughArgs=%__PassThroughArgs% %1"
129128
)
130129

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

224-
if "%__ExplicitHostArch%" == "1" (
225-
set __BinDir=%__BinDir%\%__HostArch%
226-
set __IntermediatesDir=%__IntermediatesDir%\%__HostArch%
227-
)
228-
229223
if NOT "%__SubDir%"=="" (
230224
set __BinDir=%__BinDir%\%__SubDir%
231225
set __IntermediatesDir=%__IntermediatesDir%\%__SubDir%
@@ -326,9 +320,6 @@ for /f "delims=" %%a in ("-%__RequestedBuildComponents%-") do (
326320
if not "!string:-spmi-=!"=="!string!" (
327321
set __CMakeTarget=!__CMakeTarget! spmi
328322
)
329-
if not "!string:-crosscomponents-=!"=="!string!" (
330-
set __CMakeTarget=!__CMakeTarget! crosscomponents
331-
)
332323
if not "!string:-debug-=!"=="!string!" (
333324
set __CMakeTarget=!__CMakeTarget! debug
334325
)

src/coreclr/build-runtime.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ handle_arguments_local() {
5353
__RequestedBuildComponents="$__RequestedBuildComponents $2"
5454
__ShiftArgs=1
5555
;;
56-
56+
5757
subdir|-subdir)
5858
__SubDir="$2"
5959
__ShiftArgs=1
@@ -123,11 +123,6 @@ __IntermediatesDir="$__ArtifactsIntermediatesDir/$__ConfigTriplet"
123123

124124
export __IntermediatesDir __ArtifactsIntermediatesDir
125125

126-
if [[ "$__ExplicitHostArch" == 1 ]]; then
127-
__IntermediatesDir="$__IntermediatesDir/$__HostArch"
128-
__BinDir="$__BinDir/$__HostArch"
129-
fi
130-
131126
if [[ -n "$__SubDir" ]]; then
132127
__IntermediatesDir="$__IntermediatesDir/$__SubDir"
133128
__BinDir="$__BinDir/$__SubDir"

src/coreclr/components.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ add_component(debug)
1313
# iltools and paltests should be minimal subsets, so don't add a dependency on coreclr_misc
1414
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME coreclr_misc)
1515
add_component(coreclr_misc)
16-
add_dependencies(jit coreclr_misc)
17-
add_dependencies(alljits coreclr_misc)
1816
add_dependencies(runtime coreclr_misc)
1917

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

2624
add_dependencies(runtime hosts)
27-
28-
# The cross-components build is separate, so we don't need to add a dependency on coreclr_misc
29-
add_component(crosscomponents)

src/coreclr/crosscomponents.cmake

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

src/coreclr/dlls/mscordac/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ if(CLR_CMAKE_HOST_WIN32)
216216
# debuggers and the runtime. This long form supports postmortem cross-architecture diagnostic scenarios.
217217
# It doesn't make sense to complicate install_clr for this purpose, so keep it self-contained here.
218218
set(LONG_NAME_BASE mscordaccore_${LONG_NAME_HOST_ARCH}_${LONG_NAME_TARGET_ARCH}_${FILE_VERSION})
219-
install(PROGRAMS $<TARGET_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.dll DESTINATION sharedFramework COMPONENT runtime)
220-
install(FILES $<TARGET_PDB_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.pdb DESTINATION sharedFramework/PDB COMPONENT runtime)
221-
if (NOT FEATURE_CROSSBITNESS)
222-
install(PROGRAMS $<TARGET_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.dll DESTINATION sharedFramework COMPONENT crosscomponents)
223-
install(FILES $<TARGET_PDB_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.pdb DESTINATION sharedFramework/PDB COMPONENT crosscomponents)
224-
endif()
219+
install(PROGRAMS $<TARGET_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.dll DESTINATION sharedFramework COMPONENT debug)
220+
install(FILES $<TARGET_PDB_FILE:mscordaccore> RENAME ${LONG_NAME_BASE}.pdb DESTINATION sharedFramework/PDB COMPONENT debug)
225221
endif()

src/coreclr/jit/CMakeLists.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ endif()
1818
function(create_standalone_jit)
1919

2020
set(oneValueArgs TARGET OS ARCH)
21-
set(multiValueArgs DESTINATIONS)
22-
cmake_parse_arguments(TARGETDETAILS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
21+
cmake_parse_arguments(TARGETDETAILS "" "${oneValueArgs}" "" ${ARGN})
2322

2423
if(TARGETDETAILS_OS STREQUAL "unix_osx" OR TARGETDETAILS_OS STREQUAL "unix_anyos")
2524
set(JIT_ARCH_LINK_LIBRARIES gcinfo_unix_${TARGETDETAILS_ARCH})
@@ -58,11 +57,7 @@ function(create_standalone_jit)
5857
clr_unknown_arch()
5958
endif()
6059

61-
if (TARGETDETAILS_DESTINATIONS STREQUAL "")
62-
add_jit(${TARGETDETAILS_TARGET})
63-
else()
64-
add_jit(${TARGETDETAILS_TARGET} DESTINATIONS "${TARGETDETAILS_DESTINATIONS}")
65-
endif()
60+
add_jit(${TARGETDETAILS_TARGET})
6661

6762
set_target_definitions_to_custom_os_and_arch(${ARGN})
6863
set_target_properties(${TARGETDETAILS_TARGET} PROPERTIES IGNORE_FEATURE_MERGE_JIT_AND_ENGINE TRUE)
@@ -564,7 +559,6 @@ else()
564559
endif(CLR_CMAKE_HOST_UNIX)
565560

566561
# Shared function for generating JIT
567-
# optional arguments: DESTINATIONS path
568562
function(add_jit jitName)
569563

570564
set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE)
@@ -616,7 +610,7 @@ function(add_jit jitName)
616610
endif()
617611

618612
# add the install targets
619-
install_clr(TARGETS ${jitName} ${ARGN} COMPONENT alljits)
613+
install_clr(TARGETS ${jitName} DESTINATIONS . COMPONENT alljits)
620614
endfunction()
621615

622616
set(JIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -632,32 +626,38 @@ else()
632626
set(TARGET_OS_NAME win)
633627
endif()
634628

635-
create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME} DESTINATIONS . sharedFramework)
629+
create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME})
636630
install_clr(TARGETS clrjit DESTINATIONS . sharedFramework COMPONENT jit)
637631

632+
if (NOT CLR_CROSS_COMPONENTS_BUILD)
633+
# Install the clrjit into the sharedframework dir only when we're not doing a cross-components build.
634+
# We never want to ship the cross-component JIT (it would never be used).
635+
install_clr(TARGETS clrjit DESTINATIONS sharedFramework COMPONENT alljits)
636+
endif()
637+
638638
# Enable profile guided optimization
639639
add_pgo(clrjit)
640640

641641
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
642-
create_standalone_jit(TARGET clrjit_universal_arm64_${ARCH_HOST_NAME} OS universal ARCH arm64 DESTINATIONS .)
643-
create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix_anyos ARCH x64 DESTINATIONS .)
644-
create_standalone_jit(TARGET clrjit_win_x64_${ARCH_HOST_NAME} OS win ARCH x64 DESTINATIONS .)
642+
create_standalone_jit(TARGET clrjit_universal_arm64_${ARCH_HOST_NAME} OS universal ARCH arm64)
643+
create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix_anyos ARCH x64)
644+
create_standalone_jit(TARGET clrjit_win_x64_${ARCH_HOST_NAME} OS win ARCH x64)
645645
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
646646

647647
if (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
648-
create_standalone_jit(TARGET clrjit_unix_loongarch64_${ARCH_HOST_NAME} OS unix ARCH loongarch64 DESTINATIONS .)
648+
create_standalone_jit(TARGET clrjit_unix_loongarch64_${ARCH_HOST_NAME} OS unix ARCH loongarch64)
649649
endif (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
650650

651651
if (CLR_CMAKE_TARGET_ARCH_RISCV64)
652-
create_standalone_jit(TARGET clrjit_unix_riscv64_${ARCH_HOST_NAME} OS unix ARCH riscv64 DESTINATIONS .)
652+
create_standalone_jit(TARGET clrjit_unix_riscv64_${ARCH_HOST_NAME} OS unix ARCH riscv64)
653653
else()
654-
create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm DESTINATIONS .)
654+
create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm)
655655
target_compile_definitions(clrjit_universal_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
656-
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .)
656+
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86)
657657
endif (CLR_CMAKE_TARGET_ARCH_RISCV64)
658658

659659
if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
660-
create_standalone_jit(TARGET clrjit_unix_x86_${ARCH_HOST_NAME} OS unix ARCH x86 DESTINATIONS .)
660+
create_standalone_jit(TARGET clrjit_unix_x86_${ARCH_HOST_NAME} OS unix ARCH x86)
661661
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
662662

663663
if (CLR_CMAKE_TARGET_UNIX)

0 commit comments

Comments
 (0)