Skip to content

[clr-ios] Track IL-stripping issues for CoreCLR on Apple mobile #130620

Closed

Description

@kotlarmilos

Problem

The SDK enables PublishReadyToRunStripILBodies by default for iOS-like CoreCLR composite ReadyToRun publishing. Crossgen2 strips the IL body of a non-generic method when the method definition appears in CompiledMethodDefs, but the CoreCLR interpreter can still need that IL when the compiled body cannot be used at run time.

This currently affects user-reachable scenarios.

  • Methods with opportunistic instruction-set code can carry a per-method instruction-set support fixup. For example, Crc64ParameterSet.ForwardCrc64.InitializeVectorized checks Pclmulqdq, Aes, and AdvSimd support. When run-time instruction-set support differs from the ReadyToRun baseline assumptions, the fixup rejects the compiled body and the interpreter recompiles the method from IL. A stripped body then fails at run time.
  • Assemblies loaded dynamically or through a custom or collectible AssemblyLoadContext may not be able to use code from the original composite image. The interpreter must compile those methods from IL. This affects patterns exercised by AppDomain.ExecuteAssembly, System.Runtime.Loader, DispatchProxy, and reflection-based serializers.
  • Generated test entry points can also reach the interpreter after their IL was stripped, as seen with the Regression_o_2 merged runner.

#130360 and #130468 disable IL stripping for affected test projects so CI can exercise these features. These project-level opt-outs prevent the failures but do not protect applications because stripping remains enabled by default. The runtime-async variant case was fixed directly in #130468 and is not part of the remaining work.

Proposed fix

Update the stripping policy so IL remains available whenever the interpreter can be the run-time fallback.

Related work includes #125647, #130025, #130360, and #130468.

Activity

  1. dotnet-policy-service commented on Jul 13, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
    See info in area-owners.md if you want to be subscribed.

  2. dotnet-policy-service commented on Jul 13, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli
    See info in area-owners.md if you want to be subscribed.

  3. changed the title [-]Track IL-stripping correctness for CoreCLR interpreter fallback[/-] [+][clr-ios] Track IL-stripping issues for CoreCLR on Apple mobile[/+] on Jul 13, 2026
  4. added this to the 12.0.0 milestone on Jul 13, 2026
  5. kotlarmilos commented on Jul 14, 2026

    @kotlarmilos
    MemberAuthor

    The remaining custom and collectible AssemblyLoadContext scenarios need an explicit assembly-level opt-out. One option is adding an SDK item that preserves IL bodies for selected assemblies while retaining stripping for the rest of the application.

    <ItemGroup>
      <PublishReadyToRunPreserveIL Include="MyPlugin.dll" />
      <PublishReadyToRunPreserveIL Include="ReloadableComponent.dll" />
    </ItemGroup>

    The SDK would pass these assemblies to Crossgen2, which would keep all IL bodies in the matching component assemblies. This provides a bounded solution for plugins and reloadable components without disabling PublishReadyToRunStripILBodies for the entire application. This API is only a proposal and is not currently implemented.

  6. jkotas commented on Jul 14, 2026

    @jkotas
    Member

    It should be very rare for mobile apps to use multiple load contexts. If the app really wants to have multiple assembly load contexts, the composite R2R mode won't work for the assemblies loaded in the secondary load context. The app would have to disable the composite mode - for the assemblies loaded in the secondary load contexts at least - but then the IL stripping won't work either since it is supported for composite mode only currently.

    We should keep it simple unless we hear about actual customer scenarios:

    • Avoid multiple load contexts in mobile apps
    • If the mobile app has a good reason for using multiple load context, it should opt ouf assemblies loaded into secondary load contexts from R2R using PublishReadyToRunExclude.
  7. locked and limited conversation to collaborators on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions