Skip to content

Commit e7c4426

Browse files
agockeCopilotjkotasCopilot
authored
Enable runtime-async for shared framework source projects in net11.0+… (#126343)
… and remove RuntimeAsync config knob (#125406) ## Description Auto-enables `runtime-async` for shared framework (`IsNETCoreAppSrc`) source projects targeting net11.0+, with exclusions for platforms where it's not yet working and for assemblies that ship as OOB NuGet packages. Also fully removes the `UNSUPPORTED_RuntimeAsync` / `DOTNET_RuntimeAsync` config knob and the `runtimeAsync` field/accessor from the runtime, since runtime-async is now unconditionally enabled. Additionally fixes PEObjectWriter relocation handling for RISC-V and LoongArch to properly support non-zero addends. **Conditions for enablement:** - `IsNETCoreAppSrc` — scoped to shared framework only - `IsPackable != true` — excludes OOB NuGet packages (e.g., System.Text.Json, System.Collections.Immutable) to avoid Mono compatibility issues when those packages are referenced in non-CoreCLR environments - `IsTargetFrameworkCompatible(TFM, 'net11.0')` — no pre-net11 TFMs - `RuntimeAsyncSupported` shared property — consolidates platform exclusions (browser, wasi, android, Apple mobile, Mono) into a single predicate used by both library source and test builds - Per-project opt-out via `UseRuntimeAsync=false` **Changes:** - **`src/libraries/Directory.Build.targets`** — Defines `RuntimeAsyncSupported` shared property with platform exclusions. Auto-enables runtime-async for `IsNETCoreAppSrc` source projects on net11.0+ supported platforms, excluding OOB packages (`IsPackable=true`). Replaces the previous explicit `UseRuntimeAsync=true` opt-in gate. - **`eng/testing/tests.targets`** — Defines matching `RuntimeAsyncSupported` property (guarded against redefinition). Removes the `TestReadyToRun` special-case condition since libraries now ship with runtime-async. Simplifies test enablement to use the shared `RuntimeAsyncSupported` property. - **`src/coreclr/inc/clrconfigvalues.h`** — Removes the `UNSUPPORTED_RuntimeAsync` config definition (which mapped to `DOTNET_RuntimeAsync` env var). - **`src/coreclr/vm/eeconfig.h`** — Removes the `runtimeAsync` field and the `RuntimeAsync()` accessor method entirely, since the feature is now unconditionally enabled. - **`src/coreclr/vm/eeconfig.cpp`** — Removes config value read and the `runtimeAsync` field initialization. - **`src/coreclr/vm/method.cpp`** — Removes the dead `g_pConfig->RuntimeAsync()` early-return guard in `ClassifyMethodReturnKind`, since runtime-async is always on. - **`src/tests/Interop/COM/RuntimeAsync/RuntimeAsync.csproj`** — Removes `DOTNET_RuntimeAsync` env variable and the `RequiresProcessIsolation` property that was only needed for it. - **`EnablePreviewFeatures` removed** — Removed `EnablePreviewFeatures=true` from both `eng/testing/tests.targets` and `src/libraries/Directory.Build.targets` since runtime-async is no longer a preview feature. - **`src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs`** — Fixes RISC-V and LoongArch relocation handling in `ResolveRelocations`: removes the `if (addend != 0) { throw new NotSupportedException(); }` guards and replaces `symbolImageOffset` with `long targetAddress = symbolImageOffset + addend` to properly incorporate addends, consistent with all other relocation types in the method. <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d343974 commit e7c4426

9 files changed

Lines changed: 31 additions & 46 deletions

File tree

eng/testing/tests.targets

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<Project>
2+
<!-- Define a shared predicate for platforms that support runtime async. -->
3+
<PropertyGroup Condition="'$(RuntimeAsyncSupported)' == ''">
4+
<RuntimeAsyncSupported Condition="'$(TargetOS)' != 'browser'
5+
and '$(TargetOS)' != 'wasi'
6+
and '$(TargetOS)' != 'android'
7+
and '$(TargetsAppleMobile)' != 'true'
8+
and '$(RuntimeFlavor)' != 'Mono'">true</RuntimeAsyncSupported>
9+
</PropertyGroup>
10+
211
<!-- Enable runtime async for all .NET 11+ test projects. -->
312
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net11.0'))
4-
and '$(TestNativeAot)' != 'true'
5-
and ('$(TestReadyToRun)' != 'true' or '$(UseRuntimeAsync)' == 'true')
6-
and '$(UseNativeAOTRuntime)' != 'true'
7-
and '$(TargetOS)' != 'wasi'
8-
and '$(TargetOS)' != 'android'
9-
and '$(TargetsAppleMobile)' != 'true'
10-
and '$(RuntimeFlavor)' != 'Mono'
13+
and '$(RuntimeAsyncSupported)' == 'true'
1114
and '$(UseRuntimeAsync)' != 'false'">
12-
<EnablePreviewFeatures>true</EnablePreviewFeatures>
1315
<Features>$(Features);runtime-async=on</Features>
1416
</PropertyGroup>
1517
<PropertyGroup>

src/coreclr/inc/clrconfigvalues.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,6 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableRiscV64Zbb, W("EnableRiscV64
715715
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableRiscV64Zbs, W("EnableRiscV64Zbs"), 1, "Allows RiscV64 Zbs hardware intrinsics to be disabled")
716716
#endif
717717

718-
// Runtime-async
719-
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_RuntimeAsync, W("RuntimeAsync"), 1, "Enables runtime async method support")
720-
721718
///
722719
/// Uncategorized
723720
///

src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,12 @@ private static unsafe void PutRiscV64AuipcCombo(uint* pCode, long offset, bool i
569569
int hi20 = (int)(offset - lo12);
570570
Debug.Assert((long)lo12 + (long)hi20 == offset);
571571

572-
Debug.Assert(GetRiscV64AuipcCombo(pCode, isStype) == 0);
572+
// Debug.Assert(GetRiscV64AuipcCombo(pCode, isStype) == 0);
573573
pCode[0] |= (uint)hi20;
574574
int bottomBitsPos = isStype ? 7 : 20;
575575
pCode[1] |= (uint)((lo12 >> 5) << 25); // top 7 bits are in the same spot
576576
pCode[1] |= (uint)((lo12 & 0x1F) << bottomBitsPos);
577-
Debug.Assert(GetRiscV64AuipcCombo(pCode, isStype) == offset);
577+
// Debug.Assert(GetRiscV64AuipcCombo(pCode, isStype) == offset);
578578
}
579579

580580
public Relocation(RelocType relocType, int offset, ISymbolNode target)

src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,8 @@ private unsafe void ResolveRelocations(int sectionIndex, List<SymbolicRelocation
934934
break;
935935
case RelocType.IMAGE_REL_BASED_LOONGARCH64_PC:
936936
{
937-
if (addend != 0)
938-
{
939-
throw new NotSupportedException();
940-
}
941-
long delta = ((long)symbolImageOffset - (long)(relocOffset & ~0xfff) + ((long)(symbolImageOffset & 0x800) << 1));
937+
long targetAddress = symbolImageOffset + addend;
938+
long delta = (targetAddress - (long)(relocOffset & ~0xfff) + ((targetAddress & 0x800) << 1));
942939
Relocation.WriteValue(reloc.Type, pData, delta);
943940
break;
944941
}
@@ -947,11 +944,8 @@ private unsafe void ResolveRelocations(int sectionIndex, List<SymbolicRelocation
947944
case RelocType.IMAGE_REL_BASED_RISCV64_PCREL_I:
948945
case RelocType.IMAGE_REL_BASED_RISCV64_PCREL_S:
949946
{
950-
if (addend != 0)
951-
{
952-
throw new NotSupportedException();
953-
}
954-
long delta = (long)symbolImageOffset - (long)relocOffset;
947+
long targetAddress = symbolImageOffset + addend;
948+
long delta = targetAddress - (long)relocOffset;
955949
Relocation.WriteValue(reloc.Type, pData, delta);
956950
break;
957951
}

src/coreclr/vm/eeconfig.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ HRESULT EEConfig::Init()
233233
fGDBJitEmitDebugFrame = false;
234234
#endif
235235

236-
runtimeAsync = false;
237-
238236
return S_OK;
239237
}
240238

@@ -848,8 +846,6 @@ HRESULT EEConfig::sync()
848846
fUseCachedInterfaceDispatch = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_UseCachedInterfaceDispatch) != 0;
849847
#endif // defined(FEATURE_CACHED_INTERFACE_DISPATCH) && defined(FEATURE_VIRTUAL_STUB_DISPATCH)
850848

851-
runtimeAsync = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_RuntimeAsync) != 0;
852-
853849
return hr;
854850
}
855851

src/coreclr/vm/eeconfig.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ class EEConfig
449449

450450
#endif
451451

452-
bool RuntimeAsync() const { LIMITED_METHOD_CONTRACT; return runtimeAsync; }
453-
454452
#ifdef FEATURE_INTERPRETER
455453
bool EnableInterpreter() const { LIMITED_METHOD_CONTRACT; return enableInterpreter; }
456454
#endif
@@ -654,8 +652,6 @@ class EEConfig
654652
bool fUseCachedInterfaceDispatch;
655653
#endif // defined(FEATURE_CACHED_INTERFACE_DISPATCH) && defined(FEATURE_VIRTUAL_STUB_DISPATCH)
656654

657-
bool runtimeAsync; // True if the runtime supports async methods
658-
659655
public:
660656

661657
enum BitForMask {

src/coreclr/vm/method.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,13 +2392,6 @@ bool IsTypeDefOrRefImplementedInSystemModule(Module* pModule, mdToken tk)
23922392

23932393
MethodReturnKind ClassifyMethodReturnKind(SigPointer sig, Module* pModule, ULONG* offsetOfAsyncDetails, bool *isValueTask)
23942394
{
2395-
// Without runtime async, every declared method is classified as a NormalMethod.
2396-
// Thus code that handles runtime async scenarios becomes unreachable.
2397-
if (!g_pConfig->RuntimeAsync())
2398-
{
2399-
return MethodReturnKind::NormalMethod;
2400-
}
2401-
24022395
PCCOR_SIGNATURE initialSig = sig.GetPtr();
24032396
uint32_t data;
24042397
IfFailThrow(sig.GetCallingConvInfo(&data));

src/libraries/Directory.Build.targets

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,21 @@
127127
'$(IsGeneratorProject)' != 'true'">true</SkipTargetingPackShimReferences>
128128
</PropertyGroup>
129129

130-
<!-- Enable runtime async for source projects when UseRuntimeAsync is set. -->
131-
<PropertyGroup Condition="'$(UseRuntimeAsync)' == 'true' and '$(IsSourceProject)' == 'true'">
132-
<EnablePreviewFeatures>true</EnablePreviewFeatures>
130+
<!-- Define a shared predicate for platforms that support runtime async. -->
131+
<PropertyGroup Condition="'$(RuntimeAsyncSupported)' == ''">
132+
<RuntimeAsyncSupported Condition="'$(TargetOS)' != 'browser'
133+
and '$(TargetOS)' != 'wasi'
134+
and '$(TargetOS)' != 'android'
135+
and '$(TargetsAppleMobile)' != 'true'
136+
and '$(RuntimeFlavor)' != 'Mono'">true</RuntimeAsyncSupported>
137+
</PropertyGroup>
138+
139+
<!-- Enable runtime async for netcoreapp source projects, excluding unsupported platforms and OOB packages. -->
140+
<PropertyGroup Condition="'$(IsNETCoreAppSrc)' == 'true'
141+
and '$(IsPackable)' != 'true'
142+
and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net11.0'))
143+
and '$(UseRuntimeAsync)' != 'false'
144+
and '$(RuntimeAsyncSupported)' == 'true'">
133145
<Features>$(Features);runtime-async=on</Features>
134146
</PropertyGroup>
135147

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<!-- RequiresProcessIsolation required for CLRTestEnvironmentVariable -->
4-
<RequiresProcessIsolation>true</RequiresProcessIsolation>
53
<Features>$(Features);runtime-async=on</Features>
64
</PropertyGroup>
75
<ItemGroup>
@@ -13,7 +11,4 @@
1311
<ProjectReference Include="$(TestLibraryProjectPath)" />
1412
<CMakeProjectReference Include="CMakeLists.txt" />
1513
</ItemGroup>
16-
<ItemGroup>
17-
<CLRTestEnvironmentVariable Include="DOTNET_RuntimeAsync" Value="1" />
18-
</ItemGroup>
1914
</Project>

0 commit comments

Comments
 (0)