Skip to content

chore: Modify NativeAotToolchain and suppress some warnings - #3223

Open
filzrev wants to merge 9 commits into
dotnet:masterfrom
filzrev:chore-cleanup-nativeaot-toolchain
Open

chore: Modify NativeAotToolchain and suppress some warnings#3223
filzrev wants to merge 9 commits into
dotnet:masterfrom
filzrev:chore-cleanup-nativeaot-toolchain

Conversation

@filzrev

@filzrev filzrev commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This PR contains following NativeAotToolchain related changes.

1. Modify NuGet feed URL for NativeAot90/NativeAot100/NativeAotToolchain.Net10_0

Replace to normal NuGet feed URL.

This URL seems not be actually used.
Because PackageReference to Microsoft.DotNet.ILCompiler is added when ilCompilerVersion is empty. and it's handled by <PublishAot>true</PublishAot> setting.

It might be better to remove these URLs on another PR.
(It need to verify .NET 6 NativeAot behavior because it don't support PublishAot)

2. Add RuntimeInformation.GetCoreLibDllLocation() helper method

Add helper method to get System.Private.CoreLib.dll location and suppress IL Linker related warning.
And replace existing code that using typeof(object).Assembly.Location.

3. Modify NativeAot/Generator.cs

<TrimMode>link</TrimMode> and <TrimmerDefaultAction>link</TrimmerDefaultAction> seems not supported by .NET 7 or later.

Microsoft.NET.ILLink.targets(227,5): warning : Property 'TrimmerDefaultAction' is deprecated in .NET 7 and higher and will be ignored. Use TrimMode instead.

So I've modified setting to use <TrimMode>full</TrimMode>

Comment thread src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs Outdated
Comment thread src/BenchmarkDotNet/Portability/RuntimeInformation.cs Outdated
filzrev and others added 2 commits August 5, 2026 16:46
Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>
Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>
@timcassell

Copy link
Copy Markdown
Collaborator

(It need to verify .NET 6 NativeAot behavior because it don't support PublishAot)

We should simply remove NativeAot 6.0. It was experimental until .Net 7.

/// compiled as net11.0.
/// </summary>
public static readonly IToolchain Net11_0 = CreateBuilder()
.UseNuGet("", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet11/nuget/v3/index.json")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does NativeAot11.0 work without that feed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess it should since .Net 11 preview is already public. We should at least leave a comment to include the .Net 12 feed when it's needed in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ILCompiler package is continuously published to NuGet.org from .NET 11 preview.2.
https://www.nuget.org/packages/Microsoft.DotNet.ILCompiler

So it's expected to be works.

As far as I've confirmed, specified NuGet feed seems not used after #2095 is merged

Though, It's not tested on my local environment,
Because NativeAot related tests failed on my local environment with following error.

LINK : fatal error LNK1104: cannot open file 'C:\Projects\GitHub\thirdparty\BenchmarkDotNet\tests\BenchmarkDotNet.IntegrationTests\bin\Release\net10.0\BenchmarkDotNet.IntegrationTests-1/.artifacts/\obj\BenchmarkDotNet.Autogenerated\release_net10.0_win-x64\native\BenchmarkDotNet.IntegrationTests-1.sourcelink' .0]

Comment thread src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
@filzrev

filzrev commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

I've added following changes on latest commit.

  1. Remove NativeAot60 toolchain support
    Because it's experimental feature and looks like not working after migrated to use PublishAot)

  2. Remove NuGet feeds for nativeAot
    It's not used when ilCompilerVersion is not specified.
    And it's not expected specified URL is used after NativeAotToolchain instance is generated.

Comment thread src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs Outdated
@filzrev
filzrev force-pushed the chore-cleanup-nativeaot-toolchain branch from 72a2f2c to 74d9bf5 Compare August 5, 2026 09:00
@timcassell

This comment was marked as outdated.

Comment thread src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs
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