Re-enable crossgen2 DGML log (dotnet/coreclr#27281)
authorSimon Nattress <nattress@gmail.com>
Fri, 18 Oct 2019 18:23:30 +0000 (11:23 -0700)
committerGitHub <noreply@github.com>
Fri, 18 Oct 2019 18:23:30 +0000 (11:23 -0700)
The dependency graph can be dumped to disk as an XML-based DGML file. This functionality was severed when we moved over from the CoreRT repo.

Commit migrated from https://github.com/dotnet/coreclr/commit/f3131a2490df1f97d1af4fa31763884a6bd895fe

src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
src/coreclr/src/tools/crossgen2/crossgen2/Program.cs

index a8fbe49..8858809 100644 (file)
@@ -60,6 +60,7 @@ namespace ILCompiler
         }
 
         public abstract void Compile(string outputFileName);
+        public abstract void WriteDependencyLog(string outputFileName);
 
         protected abstract void ComputeDependencyNodeDependencies(List<DependencyNodeCore<NodeFactory>> obj);
 
@@ -171,6 +172,7 @@ namespace ILCompiler
     public interface ICompilation
     {
         void Compile(string outputFileName);
+        void WriteDependencyLog(string outputFileName);
     }
 
     public sealed class ReadyToRunCodegenCompilation : Compilation
@@ -229,6 +231,15 @@ namespace ILCompiler
             }
         }
 
+        public override void WriteDependencyLog(string outputFileName)
+        {
+            using (FileStream dgmlOutput = new FileStream(outputFileName, FileMode.Create))
+            {
+                DgmlWriter.WriteDependencyGraphToStream(dgmlOutput, _dependencyGraph, _nodeFactory);
+                dgmlOutput.Flush();
+            }
+        }
+
         internal bool IsInheritanceChainLayoutFixedInCurrentVersionBubble(TypeDesc type)
         {
             // TODO: implement
index 1be1379..ace2382 100644 (file)
@@ -403,6 +403,9 @@ namespace ILCompiler
 
                 }
                 compilation.Compile(_outputFilePath);
+
+                if (_dgmlLogFileName != null)
+                    compilation.WriteDependencyLog(_dgmlLogFileName);
             }
 
             return 0;