Skip to content

Bug. Native AOT .NET 7.0 doesn't work. System.NotSupportedException: X86Serialize #2463

Closed
@Avangardum

Description

@Avangardum

I created a very simple benchmark:

[SimpleJob(RuntimeMoniker.NativeAot70)]
public class Benchmarks
{
    [Benchmark]
    public void Foo()
    {
        Thread.Sleep(5);
    }
}

When I run it, I get the following output:

"C:\Program Files\JetBrains\JetBrains Rider 2023.1.2\plugins\dpa\DotFiles\JetBrains.DPA.Runner.exe" --handle=26532 --backend-pid=15812 --etw-collect-flags=3 --detach-event-name=dpa.detach.26532 C:/Users/Yuriy/RiderProjects/BenchmarkDotNetBugReprodution/BenchmarkDotNetBugReproduction/bin/Release/net7.0/BenchmarkDotNetBugReproduction.exe
// Validating benchmarks:
// ***** BenchmarkRunner: Start   *****
// ***** Found 1 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start   *****
// start dotnet  restore -r win-x64 /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9
// command took 1.02 sec and exited with 0
// start dotnet  build -c Release -r win-x64 --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9
// command took 3.55 sec and exited with 0
// start dotnet  publish -c Release -r win-x64 --no-build --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true --output "C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9\bin\Release\net7.0\win-x64\publish" in C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9
// command took 2.9 sec and exited with 1
// ***** Done, took 00:00:07 (7.59 sec)   *****
// Found 1 benchmarks:
//   Benchmarks.Foo: NativeAOT 7.0(Runtime=NativeAOT 7.0)

Setup power plan (GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c FriendlyName: High performance)
// Build Error: Standard output: 

 Standard error:
 MSBuild version 17.7.3+4fca21998 for .NET
C:\Program Files\dotnet\sdk\7.0.403\Sdks\Microsoft.NET.ILLink.Tasks\build\Microsoft.NET.ILLink.targets(205,5): warning : Property 'TrimmerDefaultAction' is deprecated in .NET 7 and will be ignored. Use TrimMode instead. [C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9\BenchmarkDotNet.Autogenerated.csproj]
  Generating native code
EXEC : error : X86Serialize [C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9\BenchmarkDotNet.Autogenerated.csproj]
  System.NotSupportedException: X86Serialize
     at ILCompiler.HardwareIntrinsicHelpers.XArchIntrinsicConstants.FromInstructionSet(InstructionSet) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs:line 153
     at ILCompiler.HardwareIntrinsicHelpers.GetRuntimeRequiredIsaFlags(InstructionSetSupport) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs:line 70
     at ILCompiler.ExpectedIsaFeaturesRootProvider.ILCompiler.ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExpectedIsaFeaturesRootProvider.cs:line 27
     at ILCompiler.Compilation..ctor(DependencyAnalyzerBase`1, NodeFactory, IEnumerable`1, ILProvider, DebugInformationProvider, DevirtualizationManager, IInliningPolicy, Logger) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs:line 64
     at ILCompiler.ILScannerBuilder.ToILScanner() in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScannerBuilder.cs:line 83
     at ILCompiler.Program.<Run>g__RunScanner|73_4(<>c__DisplayClass73_0&) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 884
     at ILCompiler.Program.Run(String[]) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 866
     at ILCompiler.Program.Main(String[]) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 1150
C:\Program Files\dotnet\sdk\7.0.403\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets(278,5): error MSB3073: The command ""C:\Users\Yuriy\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\7.0.13\t
ools\\ilc" @"obj\Release\net7.0\win-x64\native\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9.ilc.rsp"" exited with code 1. [C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9\BenchmarkDotNet.Autogenerated.csproj]

// BenchmarkDotNet has failed to build the auto-generated boilerplate code.
// It can be found in C:\Users\Yuriy\RiderProjects\BenchmarkDotNetBugReprodution\BenchmarkDotNetBugReproduction\bin\Release\net7.0\6a5ac22a-b1e1-4db0-8019-a0b40ad5fdb9
// Please follow the troubleshooting guide: https://benchmarkdotnet.org/articles/guides/troubleshooting.html

// ** Remained 0 (0.0%) benchmark(s) to run. Estimated finish 2023-11-10 13:27 (0h 0m from now) **
Successfully reverted power plan (GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c FriendlyName: High performance)
// ***** BenchmarkRunner: Finish  *****

// * Export *
  BenchmarkDotNet.Artifacts\results\BenchmarkDotNetBugReproduction.Benchmarks-report.csv
  BenchmarkDotNet.Artifacts\results\BenchmarkDotNetBugReproduction.Benchmarks-report-github.md
  BenchmarkDotNet.Artifacts\results\BenchmarkDotNetBugReproduction.Benchmarks-report.html

// * Detailed results *
Benchmarks.Foo: NativeAOT 7.0(Runtime=NativeAOT 7.0)
Runtime = ; GC =
There are not any results runs

// * Summary *

BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2428/22H2/2022Update/SunValley2)
12th Gen Intel Core i7-12700H, 1 CPU, 20 logical and 14 physical cores
.NET SDK 7.0.403
  [Host] : .NET 7.0.13 (7.0.1323.51816), X64 RyuJIT AVX2

Job=NativeAOT 7.0  Runtime=NativeAOT 7.0

| Method | Mean | Error |
|------- |-----:|------:|
| Foo    |   NA |    NA |

Benchmarks with issues:
  Benchmarks.Foo: NativeAOT 7.0(Runtime=NativeAOT 7.0)

// * Legends *
  Mean  : Arithmetic mean of all measurements
  Error : Half of 99.9% confidence interval
  1 ns  : 1 Nanosecond (0.000000001 sec)

// ***** BenchmarkRunner: End *****
Run time: 00:00:00 (0.06 sec), executed benchmarks: 0

Global total time: 00:00:08 (8.03 sec), executed benchmarks: 0
// * Artifacts cleanup *
Artifacts cleanup is finished

Process finished with exit code 0.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions