Class NativeAotToolchainBuilder
- Namespace
- BenchmarkDotNet.Toolchains.NativeAot
- Assembly
- BenchmarkDotNet.dll
public class NativeAotToolchainBuilder : CustomDotNetCliToolchainBuilder
- Inheritance
-
NativeAotToolchainBuilder
- Inherited Members
Constructors
NativeAotToolchainBuilder()
public NativeAotToolchainBuilder()
Methods
Create()
public static NativeAotToolchainBuilder Create()
Returns
IlcGenerateCompleteTypeMetadata(bool)
This controls the generation of complete type metadata. This option is enabled by default. This is a compilation mode that prevents a situation where some members of a type are visible to reflection at runtime, but others aren't, because they weren't compiled.
public NativeAotToolchainBuilder IlcGenerateCompleteTypeMetadata(bool value)
Parameters
value
bool
Returns
IlcGenerateStackTraceData(bool)
This controls generation of stack trace metadata that provides textual names in stack traces. This option is enabled by default. This is for example the text string one gets by calling Exception.ToString() on a caught exception. With this option disabled, stack traces will still be generated, but will be based on reflection metadata alone (they might be less complete).
public NativeAotToolchainBuilder IlcGenerateStackTraceData(bool value)
Parameters
value
bool
Returns
IlcInstructionSet(string)
By default, the compiler targets the minimum instruction set supported by the target OS and architecture.
This option allows targeting newer instruction sets for better performance.
The native binary will require the instruction sets to be supported by the hardware in order to run.
For example, avx2,bmi2,fma,pclmul,popcnt,aes
will produce binary that takes advantage of instruction sets
that are typically present on current Intel and AMD processors.
public NativeAotToolchainBuilder IlcInstructionSet(string value)
Parameters
value
stringSpecify empty string ("", not null) to use the defaults.
Returns
IlcOptimizationPreference(string)
Options related to code generation.
public NativeAotToolchainBuilder IlcOptimizationPreference(string value = "Speed")
Parameters
value
string"Speed" to favor code execution speed (default), "Size" to favor smaller code size
Returns
PackagesRestorePath(string)
The directory to restore packages to (optional).
public NativeAotToolchainBuilder PackagesRestorePath(string packagesRestorePath)
Parameters
packagesRestorePath
string
Returns
RootAllApplicationAssemblies(bool)
This controls the compiler behavior where all code in the application assemblies is considered dynamically reachable. This option is disabled by default. Enabling this option (true) has a significant effect on the size of the resulting executable because it prevents removal of unused code that would otherwise happen.
public NativeAotToolchainBuilder RootAllApplicationAssemblies(bool value)
Parameters
value
bool
Returns
ToToolchain()
public override IToolchain ToToolchain()
Returns
UseLocalBuild(DirectoryInfo)
creates a NativeAOT toolchain targeting local build of ILCompiler Based on https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/nativeaot.md
public NativeAotToolchainBuilder UseLocalBuild(DirectoryInfo ilcPackages)
Parameters
ilcPackages
DirectoryInfothe path to shipping packages, example: "C:\runtime\artifacts\packages\Release\Shipping"
Returns
UseNuGet(string, string)
creates a NativeAOT toolchain targeting NuGet build of Microsoft.DotNet.ILCompiler Based on https://github.com/dotnet/runtimelab/blob/d0a37893a67c125f9b0cd8671846ff7d867df241/samples/HelloWorld/README.md#add-corert-to-your-project
public NativeAotToolchainBuilder UseNuGet(string microsoftDotNetILCompilerVersion = "", string nuGetFeedUrl = "https://api.nuget.org/v3/index.json")
Parameters
microsoftDotNetILCompilerVersion
stringthe version of Microsoft.DotNet.ILCompiler which should be used. The default is empty which maps to latest version.
nuGetFeedUrl
stringurl to NuGet feed, The default is: "https://api.nuget.org/v3/index.json"