Refactor toolchains and runtimes - #3232
Open
timcassell wants to merge 1 commit into
Open
Conversation
timcassell
force-pushed
the
refactor-toolchain-runtime
branch
from
August 16, 2026 01:51
6b15cfa to
11f4bb4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2609
Fixes #3036
Core changes:
InfrastructureMode:WithToolchain(...)sets the job'sRuntimefrom the toolchain's target runtime.WithRuntime(...)clears any explicitly set toolchain; the toolchain is then derived from the runtime when the benchmark is built.Runtimehas aVersionproperty instead ofRuntimeMoniker/MsBuildMonikerRuntimeMonikerenum replaced withstringconstants + a real parser.Runtime.Parse(string)/Runtime.TryParse(...)WasmRuntimesplit intoMonoWasmRuntime(interpreter/Jiterpreter),MonoWasmAotRuntime(AOT), andCoreWasmRuntime(CoreCLR-on-wasm, experimental).MonoRuntimesplit outMonoCoreRuntime(.NET 6+ on the Mono VM), plusMonoAotRuntime(legacy Mono AOT).*Toolchain.From(runtime, settings), orFrom(settings)for toolchains with a fixed runtime.[BuildType][Runtime]Toolchain, which sets us up for future toolchains with different build types on the same runtimes (Source Generators based Toolchain #1770/[Feature Request] Supportdotnet run benchmark.cs -c Release#2754)Behavior changes:
RuntimeandToolchainis last-wins (the coupling clears/overwrites accordingly);BDN1800warns about it.Runtime.Nameno longer includes the version —Nameis the family (e.g..NET Core);ToString()appends the version (e.g..NET Core 8.0).Breaking changes:
RuntimeMoniker— the enum is replaced bystringconstants.[SimpleJob(RuntimeMoniker.Net80)]still compiles, but code that switched on the enum or used removed members (HostProcess,NotRecognized,MonoAOTLLVM*,WasmNet*) must change.Runtime.IsAOTandAotFilterAttributeremoved — filter AOT-incompatible benchmarks withruntime is NativeAotRuntimeinstead.Runtimeabstract membersName,Version,GetDefaultToolchain.--clrVersionremoved (ClrRuntime.CreateForLocalFullNetFrameworkBuild,COMPLUS_Version) — the legacy private full-Framework-build feature is gone.--AOTCompilerModeremoved.CustomRuntimeandMonoAotLLVMRuntimeremoved.WasmRuntime/MonoRuntimesplit into the concrete types above; theMonoRuntime(name, path)ctor is gone — useWithToolchain(RoslynMonoToolchain.From(new MonoSettings { MonoPath = ... })).CoreRuntimefactory changed —CoreRuntime.CreateForNewVersion(msBuildMoniker, displayName)is replaced byCoreRuntime.From(Version version, string? platform = null).IEquatable<T>from runtimes and toolchains. Equality is still value-based viaEquals(object).NativeAotToolchainBuilder.NativeAotSettingsremoved support for adding arbitrary nuget feedsNativeAotToolchain->CsProjNativeAotToolchainR2RToolchain->CsProjR2RToolchainMonoToolchain->CsProjMonoCoreToolchainWasmToolchain->CsProjMonoWasmToolchain/CsProjMonoWasmAotToolchain/CsProjCoreWasmToolchainMonoAotToolchain->RoslynMonoAotToolchainCsProjClassicNetToolchain->CsProjFrameworkToolchainCsProjCoreToolchainand settings namespace changedBenchmarkDotNet.Toolchains.CsProj->BenchmarkDotNet.Toolchains.NetCoreAppRoslynToolchain->RoslynFrameworkToolchain/RoslynMonoToolchainRoslyn.Builder/Roslyn.Generator->RoslynBuilder/RoslynGeneratorstringpaths changed toFileInfo/DirectoryInfo(on settings;ArtifactsPathsstaysstring).CsProjGenerator(and its subclasses),DotNetCliBuilder, andDotNetCliPublishernow accept the toolchain's settings record (with the target framework moniker already resolved against the runtime) instead of separatetargetFrameworkMoniker/cliPathparameters.DotNetCliGeneratorexposes a singleSettingsproperty in place ofTargetFrameworkMoniker/CliPath/PackagesPath.Other Changes:
UnknownRuntimeinstead of throwing when the current runtime is unrecognized.RuntimeFlavorenum and--wasmRuntimeFlavorremoved.RuntimeValidatorremoved and replaced withBDN1800analyzer rule and code fixer.