From 04534a3f762c159075b79be09142959eaf17e61f Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 10 Sep 2026 21:54:31 -0500 Subject: [PATCH] Fix CoreLib trimming substitutions for interpreter-only CoreCLR (#133639) ## Summary Fixes #133615. Only include CoreCLR's JIT-specific `IsDynamicCodeCompiled` trimming substitution when `FeatureDynamicCodeCompiled` is enabled. This matches the condition used by the original getter: interpreter-only CoreCLR can support dynamic code without compiling it. Normal JIT-enabled substitution behavior is unchanged. Reenable `RuntimeFeatureTests.DynamicCode` and `DynamicCode_Jit` on Apple-mobile CoreCLR by removing their #124344 exclusions. Narrow the existing #123011 interpreter exclusion to non-Apple platforms so the corrected result does not simply cause `DynamicCode_Jit` to be skipped. Retain `SkipOnMono`, the non-Apple interpreter exclusion, and all existing assertions. This is a standalone trimming fix. It does not depend on #133378 or include WASM library-test, CI, or stack-walk workaround changes. ## Validation Built clean baselines and rebuilt the modified CoreLib for macOS arm64 and iOS simulator arm64 using **Checked CoreCLR / Release libraries**. All builds completed without warnings or errors. On an **iOS 26.5 simulator**, ran the same `RuntimeFeatureTests` class selection with `PublishReadyToRun=false`. Test-selection changes were applied before the pre-fix run and remained identical afterward. | Configuration | Executed | Passed | Failed | |---|---:|---:|---:| | Pre-fix, aggressively trimmed iOS | 11 | 9 | 2 | | Pre-fix, untrimmed iOS control | 11 | 11 | 0 | | Post-fix, aggressively trimmed iOS | 11 | 11 | 0 | | Post-fix, normal macOS JIT | 13 | 13 | 0 | The two pre-fix failures were exactly `DynamicCode_Jit` (`IsDynamicCodeCompiled` unexpectedly true) and `DynamicCode` (direct getter disagrees with `IsSupported`). Both explicitly pass after the fix. Each iOS run has one unavailable RemoteExecutor context-switch case skipped; filtered cases are not counted as executed. Results were read from application logs, rather than relying on the local `xharness apple run` exit status. Additional controls: - Two fully trimmed desktop CoreLib/probe executions pass: dynamic-code support enabled preserves compiled=true; disabled preserves compiled=false. - ILLink direct-caller inspection confirms iOS compiled=false for either feature-switch value after the fix, while desktop true/false folding remains unchanged. No device, tvOS, MacCatalyst, or release-branch execution is claimed. ## Compatibility and servicing This corrects a public return value for affected trimmed interpreter-only CoreCLR applications; compatibility documentation should follow once the PR is merged. `release/11.0` and `release/11.0-rc1` have the same getter/substitution mismatch and are candidates for a targeted .NET 11 backport after main lands. `release/10.0` lacks the same no-JIT getter implementation, so this should not be mechanically backported there. > [!NOTE] > This pull request description and code changes were generated with GitHub Copilot. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../System.Private.CoreLib/System.Private.CoreLib.csproj | 2 +- ...ons.xml => ILLink.Substitutions.DynamicCodeCompiled.xml} | 0 .../System/Runtime/CompilerServices/RuntimeFeatureTests.cs | 6 ++---- 3 files changed, 3 insertions(+), 5 deletions(-) rename src/coreclr/System.Private.CoreLib/src/ILLink/{ILLink.Substitutions.xml => ILLink.Substitutions.DynamicCodeCompiled.xml} (100%) diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 0d0f874aca3f9c..874529fa233956 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml b/src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.DynamicCodeCompiled.xml similarity index 100% rename from src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml rename to src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.DynamicCodeCompiled.xml diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeFeatureTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeFeatureTests.cs index 2eca940a3661b6..e140fae59c755c 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeFeatureTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeFeatureTests.cs @@ -19,7 +19,6 @@ public static void PortablePdb() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))] public static void DynamicCode() { Assert.Equal(RuntimeFeature.IsDynamicCodeSupported, RuntimeFeature.IsSupported("IsDynamicCodeSupported")); @@ -33,9 +32,8 @@ public static void DynamicCode() [Fact] [SkipOnMono("IsDynamicCodeCompiled returns false in cases where mono doesn't support these features")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))] - // The CoreCLR interpreter is not a JIT, so RuntimeFeature.IsDynamicCodeCompiled is false. - [ActiveIssue("https://github.com/dotnet/runtime/issues/123011", typeof(PlatformDetection), nameof(PlatformDetection.IsCoreClrInterpreter))] + // Apple mobile has interpreter-specific expectations below. + [ActiveIssue("https://github.com/dotnet/runtime/issues/123011", typeof(PlatformDetection), nameof(PlatformDetection.IsCoreClrInterpreter), nameof(PlatformDetection.IsNotAppleMobile))] public static void DynamicCode_Jit() { if (PlatformDetection.IsNativeAot)