Skip to content

crossgen2 fails on assemblies that include embedded types #67855

@AArnott

Description

@AArnott

Description

The .NET 6 runtime supports type equivalence which comes from embedding types (EmbedInteropTypes=true on a reference, or using the /link parameter to csc.exe instead of /reference for an embeddable assembly).
Crossgen2 fails to compile assemblies that contain embedded types (one that was compiled with /link).

Reproduction Steps

The minimal embeddable type in the assembly doesn't seem to repro the problem. So all I can do is offer the full original repro, ready to run (😉): via OneDrive for Business.
Just extract the .zip and run repro.cmd.

Expected behavior

crossgen completes successfully.

Actual behavior

crossgen2 crashes with this exception:

Error: [embedding-referenced-assembly]embedded-type
System.NotImplementedException: [embedding-referenced-assembly]embedded-type
   at ILCompiler.DependencyAnalysis.ReadyToRun.ModuleTokenResolver.GetModuleTokenForType(EcmaType type, Boolean throwIfNotFound)
   at ILCompiler.DependencyAnalysis.ReadyToRun.SignatureContext.GetTargetModule(TypeDesc type)
   at ILCompiler.DependencyAnalysis.ReadyToRun.TypeFixupSignature.GetData(NodeFactory factory, Boolean relocsOnly)
   at ILCompiler.DependencyAnalysis.ReadyToRun.ImportSectionNode.MaterializeSignature(NodeFactory r2rFactory)
   at ILCompiler.DependencyAnalysis.ReadyToRun.ImportSectionsTableNode.MaterializeSignature()
   at ILCompiler.DependencyAnalysis.ReadyToRun.ManifestMetadataTableNode.ComputeLastSetOfModuleIndices()
   at ILCompiler.DependencyAnalysis.ReadyToRun.ManifestMetadataTableNode.GetManifestAssemblyMvidTableData()
   at ILCompiler.DependencyAnalysis.ReadyToRun.ManifestAssemblyMvidHeaderNode.GetData(NodeFactory factory, Boolean relocsOnly)
   at ILCompiler.DependencyAnalysis.ReadyToRunObjectWriter.EmitPortableExecutable()
   at ILCompiler.ReadyToRunCodegenCompilation.Compile(String outputFile)
   at ILCompiler.Program.RunSingleCompilation(Dictionary`2 inFilePaths, InstructionSetSupport instructionSetSupport, String compositeRootPath, Dictionary`2 unrootedInputFilePaths, HashSet`1 versionBubbleModulesHash, CompilerTypeSystemContext typeSystemContext)
   at ILCompiler.Program.Run(String[] args)
   at ILCompiler.Program.Main(String[] args)

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions