From 2938f537c4926544bccddb6762d385dd95bc2716 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 10 Jul 2026 12:03:07 +0200 Subject: [PATCH 1/3] [clr-ios] Disable R2R IL-body stripping for more library tests that need IL at run time Follow-up to #130360. The SDK strips IL bodies from the Apple mobile CoreCLR composite ReadyToRun image by default, replacing each body with an invalid stub, so any test that needs the real IL at run time fails. Three more projects hit this: System.Runtime.Extensions.Tests (AppDomainTests.ExecuteAssembly invokes a stripped entry point, InvalidProgramException), System.IO.Hashing.Tests (Crc64ParameterSet.ForwardCrc64.InitializeVectorized, a Vector128 intrinsic fallback), and System.Diagnostics.StackTrace.Tests (the runtime-async V2Methods.Quuux in ToString_Async). This sets PublishReadyToRunStripILBodies to false on those three test projects, which #130360 already forwards through the _ApplePropertyNames allowlist, leaving stripping on for every other Apple mobile CoreCLR test app. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 432f1ad3-ea7c-4c6e-8f53-c6ecb80338b6 --- .../tests/System.Diagnostics.StackTrace.Tests.csproj | 1 + .../System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj | 1 + .../System.Runtime.Extensions.Tests.csproj | 1 + 3 files changed, 3 insertions(+) diff --git a/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj b/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj index 8611372f552f6a..6d939da25042f9 100644 --- a/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj +++ b/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj @@ -3,6 +3,7 @@ $(NetCoreAppCurrent) true true + false true true diff --git a/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj b/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj index 81e5ede74483d1..058bf79a8a454c 100644 --- a/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj +++ b/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj @@ -2,6 +2,7 @@ true + false $(NetCoreAppCurrent);$(NetFrameworkCurrent) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj index 7e769bdb467224..f9639376b4728c 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj @@ -3,6 +3,7 @@ true true true + false $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser From d3538a2f06e202251d93bc90377a015248594d44 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 10 Jul 2026 13:03:13 +0200 Subject: [PATCH 2/3] Disable crossgen2 IL stripping for Regression_o_2 merged runner on Apple mobile The generated merged test runner entry point Program...RunTests(TestFilter) has its IL stripped by crossgen2 --strip-il-bodies, which the interpreter on Apple mobile CoreCLR needs at runtime, causing the iossimulator CoreCLR runtime test leg to fail. Set PublishReadyToRunStripILBodies=false so the property is forwarded through _ApplePropertyNames into the Helix Apple app build, matching the approach used for the library test projects in this PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 24b062cc-cf90-4c79-868e-4c6d1fcc7c36 --- src/tests/JIT/Regression/Regression_o_2.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/JIT/Regression/Regression_o_2.csproj b/src/tests/JIT/Regression/Regression_o_2.csproj index 9728cf50929a5d..281a19fe23f1fc 100644 --- a/src/tests/JIT/Regression/Regression_o_2.csproj +++ b/src/tests/JIT/Regression/Regression_o_2.csproj @@ -2,6 +2,7 @@ True True + false From 34a217b11bcad69c97baecc96d4e36d6657bd60c Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 10 Jul 2026 14:50:19 +0200 Subject: [PATCH 3/3] [clr-ios] Gate R2R IL-body stripping on async variant compilation CopiedMethodILNode stripped the RVA IL body of a runtime-async method whenever the method's Task-returning entrypoint was compiled, because the CompiledMethodDefs gate keys on the EcmaMethod while AsyncMethodVariant records itself under its own key. The RVA body is consumed at run time only by the async variant, so the body was stripped even when the variant was not compiled into the image and had to be materialized from IL, faulting on the invalid stub. Keep the IL for an already-async method unless its async variant is present in CompiledMethodDefs. This removes the need for the per-test PublishReadyToRunStripILBodies override on System.Diagnostics.StackTrace.Tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 24b062cc-cf90-4c79-868e-4c6d1fcc7c36 --- .../ReadyToRun/CopiedMethodILNode.cs | 19 ++++++++++++++----- ...System.Diagnostics.StackTrace.Tests.csproj | 1 - 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs index 787abe81061470..6c82c6ae40fc2a 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs @@ -58,7 +58,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) if (factory.OptimizationFlags.StripILBodies && factory.OptimizationFlags.CompiledMethodDefs.Contains(_method) - && !MayNeedILAtRuntime(_method)) + && !MayNeedILAtRuntime(factory, _method)) { return new ObjectData(s_minimalILBody, Array.Empty(), 4, new ISymbolDefinitionNode[] { this }); } @@ -72,7 +72,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) return new ObjectData(bodyBytes, Array.Empty(), 4, new ISymbolDefinitionNode[] { this }); } - private static bool MayNeedILAtRuntime(MethodDesc method) + private static bool MayNeedILAtRuntime(NodeFactory factory, MethodDesc method) { if (method.HasInstantiation || method.OwningType.HasInstantiation) { @@ -80,10 +80,19 @@ private static bool MayNeedILAtRuntime(MethodDesc method) return true; } - if (method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask() && !method.IsAsync) + if (method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask()) { - // IL may be needed for async version of non-async Task-returning method - return true; + if (!method.IsAsync) + { + // IL may be needed for async version of non-async Task-returning method + return true; + } + + MethodDesc asyncVariant = method.GetAsyncVariant().GetTypicalMethodDefinition(); + if (!factory.OptimizationFlags.CompiledMethodDefs.Contains(asyncVariant)) + { + return true; + } } return false; diff --git a/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj b/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj index 6d939da25042f9..8611372f552f6a 100644 --- a/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj +++ b/src/libraries/System.Diagnostics.StackTrace/tests/System.Diagnostics.StackTrace.Tests.csproj @@ -3,7 +3,6 @@ $(NetCoreAppCurrent) true true - false true true