dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.17k stars 4.72k forks source link

ILCompiler does not recognize "sha1" and "sha2" Instruction Sets #68132

Closed adamsitnik closed 2 years ago

adamsitnik commented 2 years ago

Repro:

using System;

namespace aotRepro
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine($"base: {System.Runtime.Intrinsics.Arm.ArmBase.IsSupported}");
            Console.WriteLine($"neon: {System.Runtime.Intrinsics.Arm.AdvSimd.IsSupported}");
            Console.WriteLine($"aes: {System.Runtime.Intrinsics.Arm.Aes.IsSupported}");
            Console.WriteLine($"crc: {System.Runtime.Intrinsics.Arm.Crc32.IsSupported}");
            Console.WriteLine($"dotprod: {System.Runtime.Intrinsics.Arm.Dp.IsSupported}");
            Console.WriteLine($"rdma: {System.Runtime.Intrinsics.Arm.Rdm.IsSupported}");
            Console.WriteLine($"sha1: {System.Runtime.Intrinsics.Arm.Sha1.IsSupported}");
            Console.WriteLine($"sha2: {System.Runtime.Intrinsics.Arm.Sha256.IsSupported}");         
        }
    }
}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <RuntimeIdentifier>win-arm64</RuntimeIdentifier>
     <PlatformTarget>ARM64</PlatformTarget>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" />
    <IlcArg Include="--instructionset:sha1,sha2" />
  </ItemGroup>
</Project>
dotnet run -c Release
base: True
neon: True
aes: True
crc: True
dotprod: False
rdma: False
sha1: True
sha2: True
dotnet publish -c Release
  Generating compatible native code. To optimize for size or speed, visit https://aka.ms/OptimizeCoreRT
EXEC : error : Specified method is not supported. [C:\Projects\repro\aotRepro\aotRepro.csproj]
  System.NotSupportedException: Specified method is not supported.
     at ILCompiler.HardwareIntrinsicHelpers.Arm64IntrinsicConstants.FromInstructionSetFlags(InstructionSetFlags instruc
  tionSets)
     at ILCompiler.ExpectedIsaFeaturesRootProvider.ILCompiler.ICompilationRootProvider.AddCompilationRoots(IRootingServ
  iceProvider rootProvider)
     at ILCompiler.Compilation..ctor(DependencyAnalyzerBase`1 dependencyGraph, NodeFactory nodeFactory, IEnumerable`1 c
  ompilationRoots, ILProvider ilProvider, DebugInformationProvider debugInformationProvider, DevirtualizationManager de
  virtualizationManager, IInliningPolicy inliningPolicy, Logger logger)
     at ILCompiler.ILScannerBuilder.ToILScanner()
     at ILCompiler.Program.Run(String[] args)
     at ILCompiler.Program.Main(String[] args)

FWIW I took the names from https://github.com/dotnet/runtime/blob/ce61c09a5f6fc71d8f717d3fc4562f42171869a0/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs#L739-L740

cc @jkotas

danmoseley commented 2 years ago

Should "OptimizeCoreRT" be changed?

jkotas commented 2 years ago

Should "OptimizeCoreRT" be changed?

https://github.com/dotnet/runtime/pull/68151