Skip to content

Enable runtime-async feature switch for NativeAOT System.Private.CoreLib - #123952

Merged
agocke merged 5 commits into
mainfrom
copilot/enable-runtimeasync-feature-switch
Feb 27, 2026
Merged

Enable runtime-async feature switch for NativeAOT System.Private.CoreLib#123952
agocke merged 5 commits into
mainfrom
copilot/enable-runtimeasync-feature-switch

Conversation

CopilotAI commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Description

Enables the runtime-async compiler feature for the core libraries when building for Native AOT.

Changes

  • Added <Features>$(Features);runtime-async=on</Features> to NativeAOT System.Private.CoreLib csproj
  • Suppressed CA2252 (preview features usage) since runtime-async=on causes the compiler to inject AsyncHelpers.Await calls which are marked [RequiresPreviewFeatures]
<!-- Enable runtime async for Native AOT -->
<PropertyGroup>
<Features>$(Features);runtime-async=on</Features>
<NoWarn>$(NoWarn);CA2252</NoWarn>
</PropertyGroup>

Notes

The CA2252 suppression is project-scoped because runtime-async=on transforms all async methods via compiler-generated calls—individual method suppression isn't practical or meaningful here. This is consistent with how other runtime-async-enabled projects handle it (e.g., tests disable analyzers entirely).

Original prompt

I'd like to enable the runtimeasync feature switch for the core libraries if and only if we're building for native aot. I think we might need to plumb down another msbuild switch.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
CopilotAI changed the title [WIP] Enable runtimeasync feature switch for native aot buildsEnable runtime-async feature switch for NativeAOT System.Private.CoreLibFeb 3, 2026
CopilotAI requested a review from agockeFebruary 3, 2026 18:45
@agocke

Copy link
Copy Markdown
Member

@MichalStrehovsky Some interesting failures in loongarch and riscv here. Is there work we have to do for those platforms?

@MichalStrehovsky

Copy link
Copy Markdown
Member

@MichalStrehovsky Some interesting failures in loongarch and riscv here. Is there work we have to do for those platforms?

I think this is a JIT assert, we likely haven't done any work on Risc/Loong (we certainly haven't done things like hijacking either and there's a tracking issue somewhere).

I'd just not enable runtime-async corelib on those two architectures for now.

Btw, we also have a private copy of the framework assemblies, so we could theoretically also enable runtime-async when building native AOT runtime packs.

@MichalStrehovsky

Copy link
Copy Markdown
Member

Btw, we also have a private copy of the framework assemblies, so we could theoretically also enable runtime-async when building native AOT runtime packs.

Ah, maybe we stopped building those in a separate leg with source build. So maybe can't do that one anymore.

@agocke
agocke marked this pull request as ready for review February 26, 2026 22:42
CopilotAI review requested due to automatic review settings February 26, 2026 22:42
@agocke

Copy link
Copy Markdown
Member

I excluded loongarch and riscv and that seems to have worked

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 enables the runtime-async compiler feature for NativeAOT's System.Private.CoreLib by adding the Features=runtime-async=on property in the csproj file. The feature switch transforms async methods to use the runtime's native async support instead of compiler-generated state machines, improving performance. The PR also suppresses CA2252 warnings that arise from compiler-generated calls to AsyncHelpers.Await methods marked with preview feature attributes. The feature is currently disabled for riscv64 and loongarch64 architectures.

Changes:

  • Enabled runtime-async=on feature flag for NativeAOT System.Private.CoreLib (excluding riscv64/loongarch64)
  • Suppressed CA2252 analyzer warning for preview feature usage at the project level

@jkotas

Copy link
Copy Markdown
Member

we certainly haven't done things like hijacking either and there's a tracking issue somewhere

I am not able to find it. If there is not one, we should create it (one per arch) and link it from this change

@MichalStrehovsky

Copy link
Copy Markdown
Member

we certainly haven't done things like hijacking either and there's a tracking issue somewhere

I am not able to find it. If there is not one, we should create it (one per arch) and link it from this change

It's #122492. But we're disabling runtimeasync on LoongArch/RiscV because of RyuJIT asserts when compiling. We don't even get to hijacking.

@agocke
agocke merged commit 8dc23df into mainFeb 27, 2026
102 of 105 checks passed
@agocke
agocke deleted the copilot/enable-runtimeasync-feature-switch branch February 27, 2026 08:04
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Mar 29, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants

@agocke@MichalStrehovsky@jkotas@VSadov