Skip to content

Commit 804ed97

Browse files
authored
Remove CPP codegen for NativeAOT (#1979)
Cpp codegeneration was never part of NativeAOT, and CoreRT is not tested/used in BDN right now, so I remove that option.
1 parent 56556ab commit 804ed97

File tree

4 files changed

+7
-39
lines changed

4 files changed

+7
-39
lines changed

src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ public class Generator : CsProjGenerator
2222
internal const string NativeAotNuGetFeed = "nativeAotNuGetFeed";
2323
internal const string GeneratedRdXmlFileName = "bdn_generated.rd.xml";
2424

25-
internal Generator(string ilCompilerVersion, bool useCppCodeGenerator,
25+
internal Generator(string ilCompilerVersion,
2626
string runtimeFrameworkVersion, string targetFrameworkMoniker, string cliPath,
2727
string runtimeIdentifier, IReadOnlyDictionary<string, string> feeds, bool useNuGetClearTag,
2828
bool useTempFolderForRestore, string packagesRestorePath,
2929
bool rootAllApplicationAssemblies, bool ilcGenerateCompleteTypeMetadata, bool ilcGenerateStackTraceData, string trimmerDefaultAction)
3030
: base(targetFrameworkMoniker, cliPath, GetPackagesDirectoryPath(useTempFolderForRestore, packagesRestorePath), runtimeFrameworkVersion)
3131
{
3232
this.ilCompilerVersion = ilCompilerVersion;
33-
this.useCppCodeGenerator = useCppCodeGenerator;
3433
this.targetFrameworkMoniker = targetFrameworkMoniker;
3534
this.runtimeIdentifier = runtimeIdentifier;
3635
this.feeds = feeds;
@@ -43,7 +42,6 @@ internal Generator(string ilCompilerVersion, bool useCppCodeGenerator,
4342
}
4443

4544
private readonly string ilCompilerVersion;
46-
private readonly bool useCppCodeGenerator;
4745
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
4846
private readonly string targetFrameworkMoniker;
4947
private readonly string runtimeIdentifier;
@@ -69,7 +67,7 @@ protected override string GetBinariesDirectoryPath(string buildArtifactsDirector
6967

7068
protected override void GenerateBuildScript(BuildPartition buildPartition, ArtifactsPaths artifactsPaths)
7169
{
72-
string extraArguments = NativeAotToolchain.GetExtraArguments(useCppCodeGenerator, runtimeIdentifier);
70+
string extraArguments = NativeAotToolchain.GetExtraArguments(runtimeIdentifier);
7371

7472
var content = new StringBuilder(300)
7573
.AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetRestoreCommand(artifactsPaths, buildPartition, extraArguments)}")

src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchain.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ private static NativeAotToolchainBuilder GetBuilderForOldExperimentalFeed()
2424
=> CreateBuilder().UseNuGet("6.0.0-*", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json");
2525

2626
internal NativeAotToolchain(string displayName,
27-
string ilCompilerVersion, string ilcPath, bool useCppCodeGenerator,
27+
string ilCompilerVersion, string ilcPath,
2828
string runtimeFrameworkVersion, string targetFrameworkMoniker, string runtimeIdentifier,
2929
string customDotNetCliPath, string packagesRestorePath,
3030
Dictionary<string, string> feeds, bool useNuGetClearTag, bool useTempFolderForRestore,
3131
bool rootAllApplicationAssemblies, bool ilcGenerateCompleteTypeMetadata, bool ilcGenerateStackTraceData, string trimmerDefaultAction)
3232
: base(displayName,
33-
new Generator(ilCompilerVersion, useCppCodeGenerator, runtimeFrameworkVersion, targetFrameworkMoniker, customDotNetCliPath,
33+
new Generator(ilCompilerVersion, runtimeFrameworkVersion, targetFrameworkMoniker, customDotNetCliPath,
3434
runtimeIdentifier, feeds, useNuGetClearTag, useTempFolderForRestore, packagesRestorePath,
3535
rootAllApplicationAssemblies, ilcGenerateCompleteTypeMetadata, ilcGenerateStackTraceData, trimmerDefaultAction),
36-
new DotNetCliPublisher(customDotNetCliPath, GetExtraArguments(useCppCodeGenerator, runtimeIdentifier), GetEnvironmentVariables(ilcPath)),
36+
new DotNetCliPublisher(customDotNetCliPath, GetExtraArguments(runtimeIdentifier), GetEnvironmentVariables(ilcPath)),
3737
new Executor())
3838
{
3939
IlcPath = ilcPath;
@@ -43,8 +43,8 @@ internal NativeAotToolchain(string displayName,
4343

4444
public static NativeAotToolchainBuilder CreateBuilder() => NativeAotToolchainBuilder.Create();
4545

46-
public static string GetExtraArguments(bool useCppCodeGenerator, string runtimeIdentifier)
47-
=> useCppCodeGenerator ? $"-r {runtimeIdentifier} /p:NativeCodeGen=cpp" : $"-r {runtimeIdentifier}";
46+
public static string GetExtraArguments(string runtimeIdentifier)
47+
=> $"-r {runtimeIdentifier}";
4848

4949
// https://github.com/dotnet/corert/blob/7f902d4d8b1c3280e60f5e06c71951a60da173fb/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md#compiling-source-to-native-code-using-the-ilcompiler-you-built
5050
// we have to pass IlcPath env var to get it working

src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchainBuilder.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class NativeAotToolchainBuilder : CustomDotNetCliToolchainBuilder
1212

1313
private string ilCompilerVersion;
1414
private string ilcPath;
15-
private bool useCppCodeGenerator;
1615
private string packagesRestorePath;
1716
// we set those default values on purpose https://github.com/dotnet/BenchmarkDotNet/pull/1057#issuecomment-461832612
1817
private bool rootAllApplicationAssemblies;
@@ -59,19 +58,6 @@ public NativeAotToolchainBuilder UseLocalBuild(string newIlcPath)
5958
return this;
6059
}
6160

62-
/// <summary>
63-
/// "This approach uses transpiler to convert IL to C++, and then uses platform specific C++ compiler and linker for compiling/linking the application.
64-
/// The transpiler is a lot less mature than the RyuJIT path. If you came here to give CoreRT a try" please don't use this option.
65-
/// Based on https://github.com/dotnet/corert/blob/7f902d4d8b1c3280e60f5e06c71951a60da173fb/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md#using-cpp-code-generator
66-
/// </summary>
67-
[PublicAPI]
68-
public NativeAotToolchainBuilder UseCppCodeGenerator()
69-
{
70-
useCppCodeGenerator = true;
71-
72-
return this;
73-
}
74-
7561
/// <summary>
7662
/// The directory to restore packages to (optional).
7763
/// </summary>
@@ -148,7 +134,6 @@ public override IToolchain ToToolchain()
148134
displayName: displayName ?? (ilCompilerVersion != null ? $"ILCompiler {ilCompilerVersion}" : "local ILCompiler build"),
149135
ilCompilerVersion: ilCompilerVersion,
150136
ilcPath: ilcPath,
151-
useCppCodeGenerator: useCppCodeGenerator,
152137
runtimeFrameworkVersion: runtimeFrameworkVersion,
153138
targetFrameworkMoniker: GetTargetFrameworkMoniker(),
154139
runtimeIdentifier: runtimeIdentifier ?? GetPortableRuntimeIdentifier(),

tests/BenchmarkDotNet.IntegrationTests.ManualRunning/LocalNativeAotToolchainTests.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ public void CanBenchmarkLocalBuildUsingRyuJit()
3737

3838
CanExecute<NativeAotBenchmark>(config);
3939
}
40-
41-
[Fact]
42-
public void CanBenchmarkLocalBuildUsingCppCodeGen()
43-
{
44-
var config = ManualConfig.CreateEmpty()
45-
.AddJob(Job.Dry
46-
.WithRuntime(NativeAotRuntime.Net50)
47-
.WithToolchain(
48-
NativeAotToolchain.CreateBuilder()
49-
.UseLocalBuild(IlcPath)
50-
.UseCppCodeGenerator() // https://github.com/dotnet/corert/blob/7f902d4d8b1c3280e60f5e06c71951a60da173fb/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md#using-cpp-code-generator
51-
.ToToolchain()));
52-
53-
CanExecute<NativeAotBenchmark>(config);
54-
}
5540
}
5641

5742
[KeepBenchmarkFiles]

0 commit comments

Comments
 (0)