Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use BenchmarkDotNet with NativeAOT #66637

Closed
hez2010 opened this issue Mar 15, 2022 · 2 comments · Fixed by #66650
Closed

Cannot use BenchmarkDotNet with NativeAOT #66637

hez2010 opened this issue Mar 15, 2022 · 2 comments · Fixed by #66650

Comments

@hez2010
Copy link
Contributor

hez2010 commented Mar 15, 2022

Description

I'm using BenchmarkDotNet with NativeAOT, but it failed to build and yielded the error message:

  ...
  ILC: Method '[System.Management]System.Management.WbemObjectTextSrc..ctor()' will always throw because: Invalid IL or CLR metadata in 'Void System.Management.WbemObjectTextSrc..ctor()'
  ILC: Method '[System.Management]System.Management.WbemContext..ctor()' will always throw because: Invalid IL or CLR metadata in 'Void System.Management.WbemContext..ctor()'
  ILC: Method '[System.Management]System.Management.WbemLocator..ctor()' will always throw because: Invalid IL or CLR metadata in 'Void System.Management.WbemLocator..ctor()'
  ILC: Method '[System.Management]System.Management.WbemDefPath..ctor()' will always throw because: Invalid IL or CLR metadata in 'Void System.Management.WbemDefPath..ctor()'
  ILC: Method '[System.Management]System.Management.WbemStatusCodeText..ctor()' will always throw because: Invalid IL or CLR metadata in 'Void System.Management.WbemStatusCodeText..ctor()'
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  ...
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
  <unknown>:0: error: assembler label '' can not be undefined
EXEC : error : The method or operation is not implemented. [...\bin\Release\net6.0\bf30ca63-8eeb-4379-8a70-8cf7fe931ae7\BenchmarkDotNet.Autogenerated.csproj]
  System.NotImplementedException: The method or operation is not implemented.
     at Internal.TypeSystem.Ecma.UnmanagedPdbSymbolReader.SymUnmanagedReaderWrapperCache.SymUnmanagedReaderRcw.GetMethod(Int32 methodToken, ISymUnmanagedMethod& method)
     at Internal.TypeSystem.Ecma.UnmanagedPdbSymbolReader.GetSequencePointsForMethod(Int32 methodToken)+MoveNext()
     at ILCompiler.DependencyAnalysis.MethodCodeNode.GetNativeSequencePoints()+MoveNext()
     at ILCompiler.DependencyAnalysis.ObjectWriter.BuildDebugLocInfoMap(ObjectNode node)
     at ILCompiler.DependencyAnalysis.ObjectWriter.EmitObject(String objectFilePath, IReadOnlyCollection`1 nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger)
     at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper)
     at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper)
     at ILCompiler.Program.Run(String[] args)
     at ILCompiler.Program.Main(String[] args)

Reproduction Steps

var config = DefaultConfig.Instance
    .AddJob(Job.ShortRun
        .WithToolchain(CoreRtToolchain.CreateBuilder()
            .UseCoreRtNuGet(
                microsoftDotNetILCompilerVersion: "7.0.0-*",
                nuGetFeedUrl: "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json")
            .DisplayName("NativeAOT")
            .TargetFrameworkMoniker("net6.0")
            .ToToolchain()));
BenchmarkRunner.Run<Test>(config);

public class Test
{
    [Benchmark]
    public void SomeBenchmarkCode() { ... }
}

Then run it with dotnet run -c Release.

Expected behavior

Successfully run benchmark.

Actual behavior

Failed to build benchmark

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 15, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 15, 2022
@vitek-karas
Copy link
Member

/cc @adamsitnik

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 17, 2022
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Mar 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants