using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Text;
+using Microsoft.Diagnostics.Tracing.Parsers;
using Microsoft.Diagnostics.Tracing.Parsers.Clr;
namespace ReadyToRun.SuperIlc
{
public class BuildFolderSet
{
- private IEnumerable<BuildFolder> _buildFolders;
+ class FrameworkExclusion
+ {
+ public readonly string SimpleName;
+ public readonly string Reason;
- private IEnumerable<CompilerRunner> _compilerRunners;
+ public FrameworkExclusion(string simpleName, string reason)
+ {
+ SimpleName = simpleName;
+ Reason = reason;
+ }
+ }
- private BuildOptions _options;
+ private static readonly FrameworkExclusion[] s_frameworkExclusions =
+ {
+ new FrameworkExclusion("CommandLine", "Not a framework assembly"),
+ new FrameworkExclusion("R2RDump", "Not a framework assembly"),
+ new FrameworkExclusion("System.Runtime.WindowsRuntime", "WinRT is currently not supported"),
+ new FrameworkExclusion("xunit.performance.api", "Not a framework assembly"),
- private Buckets _frameworkCompilationFailureBuckets;
+ // TODO (DavidWr): IBC-related failures
+ new FrameworkExclusion("Microsoft.CodeAnalysis.CSharp", "Ibc TypeToken 6200019a has type token which resolves to a nil token"),
+ new FrameworkExclusion("Microsoft.CodeAnalysis", "Ibc TypeToken 620001af unable to find external typedef"),
+ new FrameworkExclusion("Microsoft.CodeAnalysis.VisualBasic", "Ibc TypeToken 620002ce unable to find external typedef"),
- private Buckets _compilationFailureBuckets;
+ // TODO (TRylek): problem related to devirtualization of method without IL - System.Enum.Equals(object)
+ new FrameworkExclusion("System.ComponentModel.TypeConverter", "TODO trylek - devirtualization of method without IL"),
+ };
- private Buckets _executionFailureBuckets;
+ private readonly IEnumerable<BuildFolder> _buildFolders;
- private long _frameworkCompilationMilliseconds;
+ private readonly IEnumerable<CompilerRunner> _compilerRunners;
- private long _compilationMilliseconds;
+ private readonly BuildOptions _options;
- private long _executionMilliseconds;
+ private readonly Buckets _frameworkCompilationFailureBuckets;
- private long _buildMilliseconds;
+ private readonly Buckets _compilationFailureBuckets;
+
+ private readonly Buckets _executionFailureBuckets;
+
+ private readonly Dictionary<string, byte> _cpaotManagedSequentialResults;
+
+ private readonly Dictionary<string, byte> _crossgenManagedSequentialResults;
- private Dictionary<string, byte> _cpaotManagedSequentialResults;
+ private readonly Dictionary<string, byte> _cpaotRequiresMarshalingResults;
- private Dictionary<string, byte> _crossgenManagedSequentialResults;
+ private readonly Dictionary<string, byte> _crossgenRequiresMarshalingResults;
- private Dictionary<string, byte> _cpaotRequiresMarshalingResults;
+ private readonly Dictionary<string, string> _frameworkExclusions;
- private Dictionary<string, byte> _crossgenRequiresMarshalingResults;
+ private long _frameworkCompilationMilliseconds;
+
+ private long _compilationMilliseconds;
+
+ private long _executionMilliseconds;
+
+ private long _buildMilliseconds;
public BuildFolderSet(
IEnumerable<BuildFolder> buildFolders,
_cpaotRequiresMarshalingResults = new Dictionary<string, byte>();
_crossgenRequiresMarshalingResults = new Dictionary<string, byte>();
+ _frameworkExclusions = new Dictionary<string, string>();
}
private void WriteJittedMethodSummary(StreamWriter logWriter)
public bool Compile()
{
- CompileFramework();
+ if (!CompileFramework())
+ {
+ return false;
+ }
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
foreach (CompilerRunner runner in _compilerRunners)
{
ProcessInfo runnerProcess = compilation[(int)runner.Index];
- if (runnerProcess == null)
+ if (runnerProcess == null || runnerProcess.IsEmpty)
{
// No runner process
}
List<ProcessInfo> compilationsToRun = new List<ProcessInfo>();
List<KeyValuePair<string, ProcessInfo[]>> compilationsPerRunner = new List<KeyValuePair<string, ProcessInfo[]>>();
+ List<string> excludedAssemblies = new List<string>();
foreach (string frameworkDll in ComputeManagedAssemblies.GetManagedAssembliesInFolder(_options.CoreRootDirectory.FullName))
{
+ string simpleName = Path.GetFileNameWithoutExtension(frameworkDll);
+ FrameworkExclusion exclusion = s_frameworkExclusions.FirstOrDefault(asm => asm.SimpleName.Equals(simpleName, StringComparison.OrdinalIgnoreCase));
+ if (exclusion != null)
+ {
+ _frameworkExclusions.Add(exclusion.SimpleName, exclusion.Reason);
+ continue;
+ }
+
ProcessInfo[] processes = new ProcessInfo[(int)CompilerIndex.Count];
compilationsPerRunner.Add(new KeyValuePair<string, ProcessInfo[]>(frameworkDll, processes));
foreach (CompilerRunner runner in frameworkRunners)
return success;
}
- public bool Build(IEnumerable<CompilerRunner> runners)
+ public bool Build()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
EXIT_CODE = 1,
CRASHED = 2,
TIMED_OUT = 3,
+ BUILD_FAILED = 4,
Count
}
executionOutcomes[(int)outcome, (int)runner.Index]++;
executionFailureOutcomeMask |= 1 << (int)outcome;
}
- if (!compilationFailed && !executionFailed)
+ else if (compilationFailed)
+ {
+ executionOutcomes[(int)ExecutionOutcome.BUILD_FAILED, (int)runner.Index]++;
+ }
+ else
{
executionOutcomes[(int)ExecutionOutcome.PASS, (int)runner.Index]++;
}
}
- if (executionFailureOutcomeMask != 0)
+ if (!anyCompilationFailed)
{
- for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
+ if (executionFailureOutcomeMask != 0)
{
- if ((executionFailureOutcomeMask & (1 << outcomeIndex)) != 0)
+ for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
{
- executionOutcomes[outcomeIndex, (int)CompilerIndex.Count]++;
+ if ((executionFailureOutcomeMask & (1 << outcomeIndex)) != 0)
+ {
+ executionOutcomes[outcomeIndex, (int)CompilerIndex.Count]++;
+ }
}
}
+ else
+ {
+ executionOutcomes[(int)ExecutionOutcome.PASS, (int)CompilerIndex.Count]++;
+ }
}
else
{
- executionOutcomes[(int)ExecutionOutcome.PASS, (int)CompilerIndex.Count]++;
+ executionOutcomes[(int)ExecutionOutcome.BUILD_FAILED, (int)CompilerIndex.Count]++;
}
}
}
if (!_options.Exe)
{
logWriter.WriteLine();
- logWriter.Write($"{totalCompilations,7} ILC |");
+ logWriter.Write($"{totalCompilations,8} ILC |");
foreach (CompilerRunner runner in _compilerRunners)
{
logWriter.Write($"{runner.CompilerName,8} |");
logWriter.WriteLine(separator);
for (int outcomeIndex = 0; outcomeIndex < (int)CompilationOutcome.Count; outcomeIndex++)
{
- logWriter.Write($"{((CompilationOutcome)outcomeIndex).ToString(),11} |");
+ logWriter.Write($"{((CompilationOutcome)outcomeIndex).ToString(),12} |");
foreach (CompilerRunner runner in _compilerRunners)
{
logWriter.Write($"{compilationOutcomes[outcomeIndex, (int)runner.Index],8} |");
if (!_options.NoExe)
{
logWriter.WriteLine();
- logWriter.Write($"{totalExecutions,7} EXE |");
+ logWriter.Write($"{totalExecutions,8} EXE |");
foreach (CompilerRunner runner in _compilerRunners)
{
logWriter.Write($"{runner.CompilerName,8} |");
logWriter.WriteLine(separator);
for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
{
- logWriter.Write($"{((ExecutionOutcome)outcomeIndex).ToString(),11} |");
+ logWriter.Write($"{((ExecutionOutcome)outcomeIndex).ToString(),12} |");
foreach (CompilerRunner runner in _compilerRunners)
{
logWriter.Write($"{executionOutcomes[outcomeIndex, (int)runner.Index],8} |");
logWriter.WriteLine();
logWriter.WriteLine("Framework compilation failures:");
FrameworkCompilationFailureBuckets.WriteToStream(logWriter, detailed: false);
+
+ logWriter.WriteLine();
+ logWriter.WriteLine("Framework exclusions:");
+ WriteFrameworkExclusions(logWriter);
}
if (foldersToBuild != 0)
}
}
- WriteFoldersBlockedWithIssues(logWriter);
+ if (_buildFolders.Count() != 0)
+ {
+ WriteFoldersBlockedWithIssues(logWriter);
+ }
+ }
+
+ private void WriteFrameworkExclusions(StreamWriter logWriter)
+ {
+ int keyLength = _frameworkExclusions.Keys.Max(key => key.Length);
+ const string SimpleNameTitle = "SIMPLE_NAME";
+ keyLength = Math.Max(keyLength, SimpleNameTitle.Length);
+ StringBuilder title = new StringBuilder();
+ title.Append(SimpleNameTitle);
+ title.Append(' ', keyLength - SimpleNameTitle.Length);
+ title.Append(" | REASON");
+ logWriter.WriteLine(title.ToString());
+ logWriter.WriteLine(new string('-', title.Length));
+ foreach (KeyValuePair<string, string> exclusion in _frameworkExclusions.OrderBy(kvp => kvp.Key, StringComparer.OrdinalIgnoreCase))
+ {
+ StringBuilder line = new StringBuilder();
+ line.Append(exclusion.Key);
+ line.Append(' ', keyLength - exclusion.Key.Length);
+ line.Append(" | ");
+ line.Append(exclusion.Value);
+ logWriter.WriteLine(line.ToString());
+ }
}
private void WritePerFolderStatistics(StreamWriter logWriter)
foreach (CompilerRunner runner in _compilerRunners)
{
ProcessInfo compilationProcess = compilation[(int)runner.Index];
- if (compilationProcess != null)
+ if (compilationProcess != null && !compilationProcess.IsEmpty)
{
string log = $"\nCOMPILE {runner.CompilerName}:{compilationProcess.Parameters.InputFileName}";
StreamWriter runnerLog = perRunnerLog[(int)runner.Index];
string combinedSetLogPath = Path.Combine(_options.OutputDirectory.FullName, "combined-" + suffix);
WriteCombinedLog(combinedSetLogPath);
+ if (_options.Framework)
+ {
+ string frameworkExclusionsFile = Path.Combine(_options.OutputDirectory.FullName, "framework-exclusions-" + suffix);
+ using (StreamWriter writer = new StreamWriter(frameworkExclusionsFile))
+ {
+ WriteFrameworkExclusions(writer);
+ }
+ }
+
if (!_options.Exe && _options.Framework)
{
string frameworkBucketsFile = Path.Combine(_options.OutputDirectory.FullName, "framework-buckets-" + suffix);