Skip to content

Disable PerfMap generation for Apple mobile platforms - #121237

Merged
kotlarmilos merged 4 commits into
dotnet:mainfrom
kotlarmilos:bugfix/r2r-ios-rid
Nov 4, 2025
Merged

Disable PerfMap generation for Apple mobile platforms#121237
kotlarmilos merged 4 commits into
dotnet:mainfrom
kotlarmilos:bugfix/r2r-ios-rid

Conversation

@kotlarmilos

@kotlarmiloskotlarmilos commented Oct 31, 2025

Copy link
Copy Markdown
Member

Description

After #121187 Crossgen2 determines cross-compilation targets by reading Crossgen2Tool.GetMetadata(MetadataKeys.TargetOS). This code path triggers PerfMapWriter, which currentl doesn't support iOS targets. This PR disables PerfMap generation for Apple mobile platforms.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@kotlarmilos

Copy link
Copy Markdown
MemberAuthor

/cc: @jkoritzinsky Please let me know if this is good approach

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Apple platform variants to the PerfMap writer by mapping additional Darwin-based operating systems (MacCatalyst, iOS, iOSSimulator, tvOS, tvOSSimulator) to the existing OSX PerfMapOSToken.

Key Changes

  • Maps five additional Apple platform variants to PerfMapOSToken.OSX in the switch expression
Comments suppressed due to low confidence (1)

src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs:126

  • The switch expression is now missing a case for TargetOS.WebAssembly which exists in the TargetOS enum (defined in src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs). This will cause a NotImplementedException at runtime when WebAssembly is used as the target OS. Add a case for TargetOS.WebAssembly with an appropriate PerfMapOSToken mapping, or add test coverage to ensure all TargetOS values are handled.
 PerfMapOSToken osToken = details.OperatingSystem switch
{
TargetOS.Unknown => PerfMapOSToken.Unknown,
TargetOS.Windows => PerfMapOSToken.Windows,
TargetOS.Linux => PerfMapOSToken.Linux,
TargetOS.OSX => PerfMapOSToken.OSX,
TargetOS.MacCatalyst => PerfMapOSToken.OSX,
TargetOS.iOS => PerfMapOSToken.OSX,
TargetOS.iOSSimulator => PerfMapOSToken.OSX,
TargetOS.tvOS => PerfMapOSToken.OSX,
TargetOS.tvOSSimulator => PerfMapOSToken.OSX,
TargetOS.FreeBSD => PerfMapOSToken.FreeBSD,
TargetOS.NetBSD => PerfMapOSToken.NetBSD,
TargetOS.SunOS => PerfMapOSToken.SunOS,
_ => throw new NotImplementedException(details.OperatingSystem.ToString())
};

@am11

am11 commented Oct 31, 2025

Copy link
Copy Markdown
Member

Shall we make

match or maybe dedup them if possible?

@jkoritzinsky

Copy link
Copy Markdown
Member

The PerfMap constants are part of the PerfMap format, so any changes would require versioning the format, which isn't worth doing for this case (especially as this format doesn't really make sense in this scenario)

@jkotas

Copy link
Copy Markdown
Member

especially as this format doesn't really make sense in this scenario

Should the right fix be to disable perfmap generation in these scenarios instead then?

@jkoritzinsky

Copy link
Copy Markdown
Member

The right fix would be to disable generation on the consumer side (ie don't pass the flag to emit PerfMaps).

Then we could block passing the flag to emit them for these platforms.

The iOS perf tests for CoreCLR aren't well configured at the moment though if they're hitting this. They're requesting ReadyToRun image generation even though it doesn't work as-is.

@jkotas

Copy link
Copy Markdown
Member

The right fix would be to disable generation on the consumer side (ie don't pass the flag to emit PerfMaps).

@kotlarmilos Can we do that instead this change?

Comment threadsrc/coreclr/tools/aot/crossgen2/Program.cs Outdated
am11
am11 approved these changes Nov 3, 2025

@am11am11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR title can be now changed to Disable PerfMap generation for Apple mobile platforms.

Comment threadsrc/coreclr/tools/aot/crossgen2/Program.cs Outdated
@kotlarmiloskotlarmilos changed the title Map Apple mobile targets to OSX in PerfMapWriter to support Crossgen2 compilationDisable PerfMap generation for Apple mobile platformsNov 3, 2025
@kotlarmilos
kotlarmilos enabled auto-merge (squash) November 3, 2025 15:42
kotlarmilos added a commit to kotlarmilos/runtime that referenced this pull request Nov 3, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kotlarmiloskotlarmilosNov 4, 2025

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I assume these changes should be ported to the SDK repo (if not dedup-ed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup, they are identical https://www.diffchecker.com/8FCIR0Ag/.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@jkoritzinsky Should this be upstreamed to the SDK, or is there a way to deduplicate it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kotlarmilos note that if you upstream this then you can't use TargetOS since that property is only set in our build.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do agree we should upstream this though, using TargetPlatformIdentifier, and set the PublishReadyToRunEmitSymbols in our build to false for Apple mobile

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@kotlarmilos

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kotlarmilos

Copy link
Copy Markdown
MemberAuthor

/ba-g Android queue timeouts dotnet/dnceng#3008

@kotlarmilos
kotlarmilos merged commit 3eb06e5 into dotnet:mainNov 4, 2025
163 of 171 checks passed
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Dec 5, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@kotlarmilos@am11@jkoritzinsky@jkotas@akoeplinger