From b88ec99ffb0b73ba9dfd52004bef498e3026ec8a Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 31 Jul 2026 11:59:51 -0700 Subject: [PATCH 1/3] Trim unused CoreCLR native components from dotnet-linker-tests build The Runtime_Release jobs in the dotnet-linker-tests pipeline built the `clr` subset, which expands to `clr.native` and therefore performs a full CoreCLR native build. That includes several components the trimming and NativeAOT tests never use, most notably the `alljits` component (six cross-target alt-JITs) and `spmi` (SuperPMI and its shims). Narrow the subset list to just the components the tests need. This drops 703 of 2837 ninja targets (~25%) from the CoreCLR native build. Measured locally at `ninja -j 4`, matching the parallelism CI uses, the native build goes from 4m03s to 3m05s (-24%). Also drop two subsets that were pulled in by `clr` but are not needed: * `clr.packages` only produces the ILAsm, ILDAsm, TestHost and Sdk.IL nupkgs, which are consumed solely by official-build publishing. * `clr.crossarchtools` is redundant here: `_BuildCrossComponents` is already set whenever `ClrRuntimeBuildSubsets` is non-empty for CoreCLR, and the cross-tool build is gated on `_BuildAnyCrossArch`, which is false for native windows-x64 and linux-x64. Validated from a clean tree with the narrowed subsets: the trimming tests (88) and the NativeAOT test apps (57) all pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ce99ab84-7dd0-4307-8dbe-47d695b514de Assisted-by: Copilot:claude-opus-5 --- eng/pipelines/runtime-linker-tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 6f3fc0eb11a7c0..602a69dfc374da 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -116,7 +116,11 @@ extends: or( eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true), eq(variables['isRollingBuild'], true)) - buildArgs: -s clr+libs+tools.illink+host.native -c $(_BuildConfig) /p:ToolsConfiguration=Debug + # This is the `clr` subset with `clr.native` (which builds every native component) + # narrowed to just the components the trimming/NativeAOT tests need. Most notably it + # drops `alljits` (the cross-target alt-JITs) and `spmi` (SuperPMI and its shims), + # none of which these tests use. + buildArgs: -s clr.runtime+clr.nativeaotruntime+clr.corelib+clr.tools+clr.nativecorelib+clr.nativeaotlibs+libs+tools.illink+host.native -c $(_BuildConfig) /p:ToolsConfiguration=Debug postBuildSteps: - template: /eng/pipelines/libraries/execute-trimming-tests-steps.yml parameters: From c9cf63743fd91945e45113c998bb5ffe7a6c7ec5 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 31 Jul 2026 12:17:39 -0700 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- eng/pipelines/runtime-linker-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 602a69dfc374da..d16b2a022987e2 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -116,9 +116,9 @@ extends: or( eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true), eq(variables['isRollingBuild'], true)) - # This is the `clr` subset with `clr.native` (which builds every native component) - # narrowed to just the components the trimming/NativeAOT tests need. Most notably it - # drops `alljits` (the cross-target alt-JITs) and `spmi` (SuperPMI and its shims), + # This replaces the previous `clr` subset (which expands to `clr.native` and builds every native component) + # with a narrower CoreCLR subset list that the trimming/NativeAOT tests need. + # Most notably it drops `alljits` (cross-target alt-JITs) and `spmi` (SuperPMI and shims), # none of which these tests use. buildArgs: -s clr.runtime+clr.nativeaotruntime+clr.corelib+clr.tools+clr.nativecorelib+clr.nativeaotlibs+libs+tools.illink+host.native -c $(_BuildConfig) /p:ToolsConfiguration=Debug postBuildSteps: From e6f7a7ef92be9d9ad812ffe4a55bb21ac538804f Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Mon, 3 Aug 2026 13:39:38 -0700 Subject: [PATCH 3/3] Install the target-specific JIT into the jit component on Windows crossgen2 and ILC don't load clrjit; they load the JIT named for the target they are compiling for, e.g. clrjit_win_x64_x64 when targeting win-x64. On Unix that JIT is already installed into the `jit` component alongside clrjit, so a build that requests only `-component runtime` (which depends on `jit`) can run them. Windows had no equivalent rule, so the target-specific JIT was only ever installed as part of `alljits`. The result is that a Windows build which selects CoreCLR native components individually, rather than doing a full native build, produces a crossgen2 that fails at runtime with "Dll was not found" as soon as it is invoked, for example while R2R compiling System.Private.CoreLib. Mirror the existing Unix rule for Windows targets. Full native builds are unaffected since `alljits` already installed these JITs; this only makes the `jit` component self-contained on Windows the way it already is on Unix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ce99ab84-7dd0-4307-8dbe-47d695b514de Assisted-by: Copilot:claude-opus-5 --- src/coreclr/jit/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 50ab6b4c5669b4..7e9791ebe60adb 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -771,6 +771,17 @@ if (CLR_CMAKE_TARGET_UNIX) endif() endif() +# crossgen2 and ILC load the target-specific JIT (e.g. clrjit_win_x64_x64) rather than clrjit, +# so it has to be part of the jit component for a build that only requests that component to be +# able to run them. This mirrors what the block above already does for Unix targets. +if (CLR_CMAKE_TARGET_WIN32) + if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) + install_clr(TARGETS clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit) + else() + install_clr(TARGETS clrjit_win_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit) + endif() +endif() + if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_PGO_INSTRUMENT) # Copy PGO dependency to target dir set(PGORT_DLL "pgort140.dll")