Skip to content

Conversation

@BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Jan 12, 2026

This is achieved by using already existing properties in the sdk: PublishReadyToRun and PublishReadyToRunComposite. The compositer2r toolchain adds these properties to a standard project template. In order to test with custom built runtime, the toolchain reuses the already existing customruntimepack and aotcompilerpath bdn args.

Example command used locally from microbenchmarks project:

dotnet run -c Release -f net10.0 --runtimes r2r10_0 --filter "System.Tests.Perf_Int32.TryFormat" --customruntimepack /home/vbrezae/runtime3/artifacts/bin/microsoft.netcore.app.runtime.linux-arm64/Release/ --aotcompilerpath /home/vbrezae/runtime3/artifacts/packages/Release/Shipping/crossgen2pack/

@BrzVlad BrzVlad force-pushed the feature-composite-r2r branch 2 times, most recently from f203c40 to 2fd5f7f Compare January 15, 2026 17:44
Copy link
Collaborator

@timcassell timcassell left a comment

Choose a reason for hiding this comment

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

There has been user interest in a R2R toolchain (#2514). I think it would be good to make it work for general use, not just custom runtime. Could also make "Composite" an optional setting.

@BrzVlad BrzVlad force-pushed the feature-composite-r2r branch from 2fd5f7f to 3f4c8e8 Compare January 16, 2026 13:05
@BrzVlad
Copy link
Member Author

BrzVlad commented Jan 16, 2026

There has been user interest in a R2R toolchain (#2514). I think it would be good to make it work for general use, not just custom runtime. Could also make "Composite" an optional setting.

@timcassell I didn't really make it clear, but it actually works already with a normal sdk. If there is no passed custom runtime pack and crossgen2 pack then the TrickRuntimePackLocation target has no effect.

On a separate note, after rebasing to latest main, I tried using the locally built bdn with a sample project. The autogenerated project failed to build with the following error:

/home/vbrezae/.dotnet/sdk/10.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(467,5): error : Unhandled exception. System.CommandLine.CommandLineException: Multiple input files matching same simple name /home/vbrezae/Xamarin/tests/bdn-test/bdn-proj/bin/Release/net10.0/bdn-test-CompositeR2R-1/obj/BenchmarkDotNet.Autogenerated/release_net10.0_linux-arm64/bdn-test-CompositeR2R-1.dll /home/vbrezae/Xamarin/tests/bdn-test/bdn-proj/bin/Release/net10.0/bdn-test-CompositeR2R-1/bin/Release/net10.0/linux-arm64/publish/bdn-test-CompositeR2R-1.dll [/home/vbrezae/Xamarin/tests/bdn-test/bdn-proj/bin/Release/net10.0/bdn-test-CompositeR2R-1/BenchmarkDotNet.Autogenerated.csproj::TargetFramework=net10.0]

This error is triggered by crossgen2 when it receives the same assembly twice as an input. As you can see in the error message, it receives the bdn-test-CompositeR2R-1.dll twice. One usage comes from the obj folder which is suspicious. After a bit of bisecting, turns out that this started happening after 9368a7d. Would you be able to take a look at this ?

@timcassell
Copy link
Collaborator

That sounds like the same issue as #2931 (comment). Thanks for finding the problematic commit. I'll take a look when I get some time.

@BrzVlad
Copy link
Member Author

BrzVlad commented Jan 19, 2026

@timcassell Thanks!! #2935 did indeed fix the issue.

Regarding the simple R2R support, does it sound good to rename the toolchain/moniker to ex. R2R10_0 and have an additional --composite bdn arg that enables composite r2r ?

cc @adamsitnik

@timcassell
Copy link
Collaborator

I do think it should be renamed, and add public static readonly IToolchain Net10_0 etc fields like other toolchains, and add versions at least as far back as current supported runtimes (net8.0), optionally as far back as R2R was supported (netcoreapp3.0 according to CoPilot, but optional since users could manually construct the toolchain for the old runtimes if they need it).

I think we don't actually need a composite option in the toolchain, just always have it enabled. Users can use MsBuildArgument to override it if they want.

@timcassell
Copy link
Collaborator

Also please add integration tests.

@timcassell
Copy link
Collaborator

timcassell commented Jan 19, 2026

Also I think you should add public class R2RRuntime : CoreRuntime so it will have the correct RuntimeMoniker. And update ToolchainExtensions.GetToolchain to recognize it.

This is achieved by using already existing properties in the sdk: PublishReadyToRun and PublishReadyToRunComposite. The compositer2r toolchain adds these properties to a standar project template. In order to test with custom built runtime, the toolchain reuses the already existing `customruntimepack` and `aotcompilerpath` bdn args.

Example command used locally from microbenchmarks project:

dotnet run -c Release -f net10.0 --runtimes compositer2r10_0 --filter "System.Tests.Perf_Int32.TryFormat" --customruntimepack /home/vbrezae/runtime3/artifacts/bin/microsoft.netcore.app.runtime.linux-arm64/Release/ --aotcompilerpath /home/vbrezae/runtime3/artifacts/packages/Release/Shipping/crossgen2pack/
@BrzVlad BrzVlad force-pushed the feature-composite-r2r branch from 35593a6 to 072dcd5 Compare January 20, 2026 11:04
This only checks that using r2r runtime builds and runs. We are not checking at runtime that we are actually running r2r code.
@BrzVlad BrzVlad force-pushed the feature-composite-r2r branch from 072dcd5 to 06f74af Compare January 20, 2026 14:28
@BrzVlad
Copy link
Member Author

BrzVlad commented Jan 20, 2026

@timcassell I believe I've addressed all your comments. The newly added test is passing now, it is only testing the build step, there is no check at runtime. We could probably check the existence of some r2r binaries but I don't think it is really worth it and it would just make it susceptible to false positive failures in the future.

@BrzVlad BrzVlad force-pushed the feature-composite-r2r branch from ba8dbec to da825a5 Compare January 21, 2026 08:22
@timcassell timcassell force-pushed the feature-composite-r2r branch from 89c8420 to 6a9aaa5 Compare January 21, 2026 11:22
Copy link
Collaborator

@timcassell timcassell left a comment

Choose a reason for hiding this comment

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

Thanks @BrzVlad

@timcassell timcassell merged commit a3b4236 into dotnet:master Jan 21, 2026
11 checks passed
@timcassell timcassell added this to the v0.16.0 milestone Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants