Skip to content

Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs#53947

Merged
kotlarmilos merged 4 commits intodotnet:mainfrom
kotlarmilos:r2r-strip-il-bodies-apple-rids
Apr 28, 2026
Merged

Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs#53947
kotlarmilos merged 4 commits intodotnet:mainfrom
kotlarmilos:r2r-strip-il-bodies-apple-rids

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Apr 17, 2026

Description

Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-), pass --strip-il-bodies to crossgen2 by default via PublishReadyToRunCrossgen2ExtraArgs when composite R2R is enabled (PublishReadyToRunComposite=true), controllable via the PublishReadyToRunStripILBodies MSBuild property. The composite gate is required because crossgen2 only accepts --strip-il-bodies in composite mode.

Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-,
maccatalyst-), pass --strip-il-bodies to crossgen2 by default via
PublishReadyToRunCrossgen2ExtraArgs when composite R2R is enabled,
controllable via the PublishReadyToRunStripILBodies MSBuild property.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 09:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the SDK’s ReadyToRun crossgen2 invocation defaults for Apple mobile RuntimeIdentifiers to match dotnet/runtime behavior, enabling IL body stripping when composite ReadyToRun compilation is used.

Changes:

  • Append --strip-il-bodies to PublishReadyToRunCrossgen2ExtraArgs for ios-, tvos-, iossimulator-, tvossimulator-, and maccatalyst- RIDs.
  • Gate the new flag on PublishReadyToRunComposite=true (since crossgen2 only accepts it in composite mode) and allow opt-out via PublishReadyToRunStripILBodies=false.

Comment thread src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets Outdated
Copy link
Copy Markdown
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this interact with the partial R2R functionality?

We may need to limit this to non-partial R2R compilations (so make it another parameter on RunReadyToRunCompiler and dynamically add it in the correct cases).

Address review feedback: instead of injecting --strip-il-bodies via
PublishReadyToRunCrossgen2ExtraArgs (which applies to every crossgen2
invocation, including per-assembly partial R2R compilations batched
through the same target), expose a new Crossgen2CompositeExtraCommandLineArgs
parameter on the RunReadyToRunCompiler task and append it only when the
CompilationEntry is the composite build entry (CreateCompositeImage=true
and PartialCompile=false).

Also skip the flag when PublishReadyToRunPartialAssemblies or
PublishReadyToRunCompositeExclusions are specified, since those
scenarios leave some methods IL-only and need the IL bodies at runtime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos
Copy link
Copy Markdown
Member Author

@jkoritzinsky Introduced PublishReadyToRunCrossgen2CompositeExtraArgs to gate on full composite R2R compilation

Comment thread src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs Outdated
Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
@kotlarmilos
Copy link
Copy Markdown
Member Author

/ba-g windows jobs ran longer than the maximum time of 150 minutes

@kotlarmilos kotlarmilos merged commit 1ec3763 into dotnet:main Apr 28, 2026
16 of 24 checks passed
@MichaelSimons
Copy link
Copy Markdown
Member

MichaelSimons commented Apr 28, 2026

I suspect this change caused a regression. The job timeouts seem are related. See the failing builds at: https://dev.azure.com/dnceng-public/public/_build?definitionId=101&_a=summary&repositoryFilter=63&branchFilter=324%2C324 as well as main PRs.

AI Analysis:

Root cause: Commit 1ec3763 (PR #53947) added @(PublishReadyToRunPartialAssemblies) and @(PublishReadyToRunCompositeExclusions) item list references
inside a condition on lines 50-54. MSBuild forbids @() item references in property-level conditions (MSB4099). This causes every build that
evaluates this file to fail, not just Apple mobile RID builds.

Fix: Remove the @() item checks from the PropertyGroup conditions. Since this PropertyGroup is evaluated at import time (not inside a target), item lists
aren't even populated yet — so the @() == '' checks were always going to be true anyway. The cleanest fix is to drop those two item-list conditions and keep
only the property-based conditions. The _CreateR2RImages target (where the property is consumed) already runs at publish time when items are available, and
the RunReadyToRunCompiler task code can handle the composite exclusion logic.

Please either make a quick fix or revert immediately to unblock while investigating. TIA

@kotlarmilos
Copy link
Copy Markdown
Member Author

I suspect this change caused a regression. The job timeouts seem are related. See the failing builds at: https://dev.azure.com/dnceng-public/public/_build?definitionId=101&_a=summary&repositoryFilter=63&branchFilter=324%2C324 as well as main PRs.

AI Analysis:

Root cause: Commit 1ec3763 (PR #53947) added @(PublishReadyToRunPartialAssemblies) and @(PublishReadyToRunCompositeExclusions) item list references inside a condition on lines 50-54. MSBuild forbids @() item references in property-level conditions (MSB4099). This causes every build that evaluates this file to fail, not just Apple mobile RID builds.

Fix: Remove the @() item checks from the PropertyGroup conditions. Since this PropertyGroup is evaluated at import time (not inside a target), item lists aren't even populated yet — so the @() == '' checks were always going to be true anyway. The cleanest fix is to drop those two item-list conditions and keep only the property-based conditions. The _CreateR2RImages target (where the property is consumed) already runs at publish time when items are available, and the RunReadyToRunCompiler task code can handle the composite exclusion logic.

Please either make a quick fix or revert immediately to unblock while investigating. TIA

This is correct, my error. I missed WebAssembly jobs and didn't notice the msbuild failure there. Please proceed with the revert and I will follow-up with #54143

dsplaisted pushed a commit that referenced this pull request Apr 29, 2026
…3947)"

This reverts commit 1ec3763.

The reverted change used @(ItemList) references in PropertyGroup conditions
in Microsoft.NET.CrossGen.targets, which is not allowed by MSBuild (MSB4099).
This breaks all builds that evaluate this file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kotlarmilos added a commit to kotlarmilos/sdk that referenced this pull request Apr 29, 2026
Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-),
pass --strip-il-bodies to crossgen2 by default via PublishReadyToRunCrossgen2CompositeExtraArgs
when composite R2R is enabled (PublishReadyToRunComposite=true), controllable via the
PublishReadyToRunStripILBodies MSBuild property. The composite gate is required because
crossgen2 only accepts --strip-il-bodies in composite mode.

This re-applies dotnet#53947 (reverted in dotnet#54135) with the MSB4099 fix: the property assignments
that reference @(PublishReadyToRunPartialAssemblies) and @(PublishReadyToRunCompositeExclusions)
items are placed inside the _PrepareForReadyToRunCompilation target body so the item references
are evaluated at target time rather than at import time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kotlarmilos added a commit to kotlarmilos/sdk that referenced this pull request Apr 29, 2026
Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-),
pass --strip-il-bodies to crossgen2 by default via PublishReadyToRunCrossgen2CompositeExtraArgs
when composite R2R is enabled (PublishReadyToRunComposite=true), controllable via the
PublishReadyToRunStripILBodies MSBuild property. The composite gate is required because
crossgen2 only accepts --strip-il-bodies in composite mode.

This re-applies dotnet#53947 (reverted in dotnet#54135) with the MSB4099 fix: the property assignments
that reference @(PublishReadyToRunPartialAssemblies) and @(PublishReadyToRunCompositeExclusions)
items are placed inside the _PrepareForReadyToRunCompilation target body so the item references
are evaluated at target time rather than at import time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kotlarmilos added a commit to kotlarmilos/sdk that referenced this pull request Apr 29, 2026
Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-),
pass --strip-il-bodies to crossgen2 by default via PublishReadyToRunCrossgen2CompositeExtraArgs
when composite R2R is enabled (PublishReadyToRunComposite=true), controllable via the
PublishReadyToRunStripILBodies MSBuild property. The composite gate is required because
crossgen2 only accepts --strip-il-bodies in composite mode.

This re-applies dotnet#53947 (reverted in dotnet#54135) with the MSB4099 fix: the property assignments
that reference @(PublishReadyToRunPartialAssemblies) and @(PublishReadyToRunCompositeExclusions)
items are placed inside the _PrepareForReadyToRunCompilation target body so the item references
are evaluated at target time rather than at import time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants