Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
displayName: 'Install .NET Core SDK'
inputs:
packageType: sdk
version: 8.x
version: 10.x
installationPath: $(Agent.ToolsDirectory)/dotnet

- ${{ if eq(parameters.agentOs, 'Windows_NT') }}:
Expand Down
1 change: 0 additions & 1 deletion src/AnalyzeAsm/AnalyzeAsm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
15 changes: 15 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="3.0.0-preview.3.26172.108" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)util\CommandLineHelpers.cs" />
</ItemGroup>

</Project>
33 changes: 16 additions & 17 deletions src/cijobs/CIJobsRootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,37 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading.Tasks;

namespace ManagedCodeGen
{
internal sealed class CIJobsRootCommand : CliRootCommand
internal sealed class CIJobsRootCommand : RootCommand
{
public CliOption<string> Server { get; } =
public Option<string> Server { get; } =
new("--server", "-s") { Description = "Url of the server. Defaults to https://ci.dot.net/" };
public CliOption<string> JobName { get; } =
public Option<string> JobName { get; } =
new("--job", "-j") { Description = "Name of the job." };
public CliOption<string> BranchName { get; } =
public Option<string> BranchName { get; } =
new("--branch", "-b") { DefaultValueFactory = _ => "master", Description = "Name of the branch." };
public CliOption<string> RepoName { get; } =
public Option<string> RepoName { get; } =
new("--repo", "-r") { DefaultValueFactory = _ => "dotnet_coreclr", Description = "Name of the repo (e.g. dotnet_corefx or dotnet_coreclr)." };
public CliOption<string> MatchPattern { get; } =
public Option<string> MatchPattern { get; } =
new("--match", "-m") { Description = "Regex pattern used to select jobs output." };
public CliOption<int> JobNumber { get; } =
public Option<int> JobNumber { get; } =
new("--number", "-n") { Description = "Job number." };
public CliOption<bool> ShowLastSuccessful { get; } =
public Option<bool> ShowLastSuccessful { get; } =
new("--last-successful", "-l") { Description = "Show last successful build." };
public CliOption<string> Commit { get; } =
public Option<string> Commit { get; } =
new("--commit", "-c") { Description = "List build at this commit." };
public CliOption<bool> ShowArtifacts { get; } =
public Option<bool> ShowArtifacts { get; } =
new("--artifacts", "-a") { Description = "Show job artifacts on server." };
public CliOption<string> OutputPath { get; } =
public Option<string> OutputPath { get; } =
new("--output", "-o") { Description = "The path where output will be placed." };
public CliOption<string> OutputRoot { get; } =
public Option<string> OutputRoot { get; } =
new("--output-root") { Description = "The root directory where output will be placed. A subdirectory named by job and build number will be created within this to store the output." };
public CliOption<bool> Unzip { get; } =
public Option<bool> Unzip { get; } =
new("--unzip", "-u") { Description = "Unzip copied artifacts" };
public CliOption<string> ContentPath { get; } =
public Option<string> ContentPath { get; } =
new("--ContentPath", "-p") { Description = "Relative product zip path. Default is artifact/bin/Product/*zip*/Product.zip" };

public ParseResult Result;
Expand All @@ -45,7 +44,7 @@ public CIJobsRootCommand(string[] args) : base("Continuous integration build job
{
List<string> errors = new();

CliCommand listCommand = new("list", "List jobs on ci.dot.net for the repo.")
Command listCommand = new("list", "List jobs on ci.dot.net for the repo.")
{
Server,
JobName,
Expand Down Expand Up @@ -104,7 +103,7 @@ public CIJobsRootCommand(string[] args) : base("Continuous integration build job

Subcommands.Add(listCommand);

CliCommand copyCommand = new("copy", @"Copies job artifacts from ci.dot.net. This
Command copyCommand = new("copy", @"Copies job artifacts from ci.dot.net. This
command copies a zip of artifacts from a repo (defaulted to
dotnet_coreclr). The default location of the zips is the
Product sub-directory, though that can be changed using the
Expand Down
12 changes: 6 additions & 6 deletions src/cijobs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public async Task<int> RunAsync(string name)
return await CopyAsync(cic);
}

private T Get<T>(CliOption<T> option) => _command.Result.GetValue(option);
private T Get<T>(Option<T> option) => _command.Result.GetValue(option);

private static Task<int> Main(string[] args) =>
new CliConfiguration(new CIJobsRootCommand(args).UseVersion())
{
EnableParseErrorReporting = true
}.InvokeAsync(args);
private static Task<int> Main(string[] args)
{
var command = new CIJobsRootCommand(args).UseVersion();
return command.Parse(args).InvokeAsync();
}

// List jobs and their details from the given project on .NETCI Jenkins instance.
// List functionality:
Expand Down
3 changes: 0 additions & 3 deletions src/cijobs/cijobs.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetPathOfFileAbove(target-framework.props))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(jit-include.props))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetPathOfFileAbove(target-framework.props))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(jit-include.props))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/jit-analyze/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,11 @@ public static Dictionary<string, int> DiffInText(string diffPath, string basePat

private T Get<T>(Option<T> option) => _command.Result.GetValue(option);

private static int Main(string[] args) =>
new CommandLineConfiguration(new JitAnalyzeRootCommand(args).UseVersion()).Invoke(args);
private static int Main(string[] args)
{
var command = new JitAnalyzeRootCommand(args).UseVersion();
return command.Parse(args).Invoke();
}

public int Run()
{
Expand Down
3 changes: 0 additions & 3 deletions src/jit-analyze/jit-analyze.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetPathOfFileAbove(target-framework.props))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(jit-include.props))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/jit-dasm-pmi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ public int Run()
private T Get<T>(Option<T> option) => _command.Result.GetValue(option);
private T Get<T>(Argument<T> arg) => _command.Result.GetValue(arg);

private static int Main(string[] args) =>
new CommandLineConfiguration(new JitDasmPmiRootCommand(args).UseVersion()).Invoke(args);
private static int Main(string[] args)
{
var command = new JitDasmPmiRootCommand(args).UseVersion();
return command.Parse(args).Invoke();
}

public List<AssemblyInfo> GenerateAssemblyWorklist()
{
Expand Down
3 changes: 0 additions & 3 deletions src/jit-dasm-pmi/jit-dasm-pmi.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetPathOfFileAbove(target-framework.props))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(jit-include.props))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/jit-dasm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public int Run()
private T Get<T>(Option<T> option) => _command.Result.GetValue(option);
private T Get<T>(Argument<T> arg) => _command.Result.GetValue(arg);

private static int Main(string[] args) =>
new CommandLineConfiguration(new JitDasmRootCommand(args).UseVersion()).Invoke(args);
private static int Main(string[] args)
{
var command = new JitDasmRootCommand(args).UseVersion();
return command.Parse(args).Invoke();
}

public List<AssemblyInfo> GenerateAssemblyWorklist()
{
Expand Down
3 changes: 0 additions & 3 deletions src/jit-dasm/jit-dasm.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetPathOfFileAbove(target-framework.props))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(jit-include.props))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
3 changes: 0 additions & 3 deletions src/jit-decisions-analyze/jit-decisions-analyze.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetPathOfFileAbove(target-framework.props))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(jit-include.props))" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
149 changes: 149 additions & 0 deletions src/jit-diff/JitDiffRootCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Parsing;

namespace ManagedCodeGen
{
internal sealed class JitDiffRootCommand : RootCommand
{
public Option<string> BasePath { get; } =
new("--base", "-b") { Description = "The base compiler directory or tag. Will use crossgen, corerun, or clrjit from this directory.", Arity = ArgumentArity.ZeroOrOne };
public Option<string> DiffPath { get; } =
new("--diff", "-d") { Description = "The diff compiler directory or tag. Will use crossgen, corerun, or clrjit from this directory.", Arity = ArgumentArity.ZeroOrOne };
public Option<string> CrossgenExe { get; } =
new("--crossgen") { Description = "The crossgen or crossgen2 compiler exe. When this is specified, will use clrjit from the --base and --diff directories with this crossgen." };
public Option<string> OutputPath { get; } =
new("--output", "-o") { Description = "The output path." };
public Option<bool> NoAnalyze { get; } =
new("--noanalyze") { Description = "Do not analyze resulting base, diff dasm directories. (By default, the directories are analyzed for diffs.)" };
public Option<bool> Sequential { get; } =
new("--sequential", "-s") { Description = "Run sequentially; don't do parallel compiles." };
public Option<string> Tag { get; } =
new("--tag", "-t") { Description = "Name of root in output directory. Allows for many sets of output." };
public Option<bool> CoreLib { get; } =
new("--corelib", "-c") { Description = "Diff System.Private.CoreLib.dll." };
public Option<bool> Frameworks { get; } =
new("--frameworks", "-f") { Description = "Diff frameworks." };
public Option<string> Metric { get; } =
new("--metrics", "-m") { Description = "Comma-separated metric to use for diff computations. Available metrics: CodeSize(default), PerfScore, PrologSize, InstrCount, AllocSize, ExtraAllocBytes, DebugClauseCount, DebugVarCount" };
public Option<bool> Benchmarks { get; } =
new("--benchmarks") { Description = "Diff core benchmarks." };
public Option<bool> Tests { get; } =
new("--tests") { Description = "Diff all tests." };
public Option<bool> GCInfo { get; } =
new("--gcinfo") { Description = "Add GC info to the disasm output." };
public Option<bool> DebugInfo { get; } =
new("--debuginfo") { Description = "Add Debug info to the disasm output." };
public Option<bool> Verbose { get; } =
new("--verbose", "-v") { Description = "Enable verbose output." };
public Option<bool> NoDiffable { get; } =
new("--nodiffable") { Description = "Generate non-diffable asm (pointer values will be left in output)." };
public Option<string> CoreRoot { get; } =
new("--core_root") { Description = "Path to test CORE_ROOT." };
public Option<string> TestRoot { get; } =
new("--test_root") { Description = "Path to test tree. Use with --benchmarks or --tests." };
public Option<string> BaseRoot { get; } =
new("--base_root") { Description = "Path to root of base dotnet/runtime repo." };
public Option<string> DiffRoot { get; } =
new("--diff_root") { Description = "Path to root of diff dotnet/runtime repo." };
public Option<string> Arch { get; } =
new("--arch") { Description = "Architecture to diff (x86, x64)." };
public Option<string> Build { get; } =
new("--build") { Description = "Build flavor to diff (Checked, Debug)." };
public Option<string> AltJit { get; } =
new("--altjit") { Description = "If set, the name of the altjit to use (e.g., clrjit_win_arm64_x64.dll)." };
public Option<bool> Pmi { get; } =
new("--pmi") { Description = "Run asm diffs via pmi." };
public Option<bool> Cctors { get; } =
new("--cctors") { Description = "With --pmi, jit and run cctors before jitting other methods" };
public Option<List<string>> AssemblyList { get; } =
new("--assembly") { Description = "Run asm diffs on a given set of assemblies. An individual item can be an assembly or a directory tree containing assemblies." };
public Option<bool> Tsv { get; } =
new("--tsv") { Description = "Dump analysis data to diffs.tsv in output directory." };
public Option<bool> Tier0 { get; } =
new("--tier0") { Description = "Diff tier0 codegen where possible." };
public Option<int> Count { get; } =
new("--count") { Description = "Provide the count parameter to jit-analyze (default 20)." };

public Option<string> JobName { get; } =
new("--job", "-j") { Description = "Name of the job." };
public Option<string> Number { get; } =
new("--number", "-n") { Description = "Job number." };
public Option<bool> LastSuccessful { get; } =
new("--last_successful", "-l") { Description = "Last successful build." };
public Option<string> BranchName { get; } =
new("--branch", "-b") { Description = "Name of branch." };

public ParseResult Result { get; private set; }
public jitdiff.Commands SelectedCommand { get; private set; }

public JitDiffRootCommand(string[] args) : base("Managed codegen diff orchestrator")
{
Command diffCommand = new("diff", "Run asm diffs via crossgen.")
{
BasePath, DiffPath, CrossgenExe, OutputPath, NoAnalyze, Sequential, Tag, CoreLib, Frameworks, Metric,
Benchmarks, Tests, GCInfo, DebugInfo, Verbose, NoDiffable, CoreRoot, TestRoot, BaseRoot, DiffRoot,
Arch, Build, AltJit, Pmi, Cctors, AssemblyList, Tsv, Tier0, Count
};
diffCommand.SetAction(result => Execute(result, jitdiff.Commands.Diff));
Subcommands.Add(diffCommand);

Command listCommand = new("list", "List defaults and available tools in config.json.")
{
Verbose
};
listCommand.SetAction(result => Execute(result, jitdiff.Commands.List));
Subcommands.Add(listCommand);

Command installCommand = new("install", "Install tool in config.json.")
{
JobName, Number, LastSuccessful, BranchName, Verbose
};
installCommand.SetAction(result => Execute(result, jitdiff.Commands.Install));
Subcommands.Add(installCommand);

Command uninstallCommand = new("uninstall", "Uninstall tool from config.json.")
{
Tag
};
uninstallCommand.SetAction(result => Execute(result, jitdiff.Commands.Uninstall));
Subcommands.Add(uninstallCommand);
}

private int Execute(ParseResult result, jitdiff.Commands command)
{
Result = result;
SelectedCommand = command;

try
{
jitdiff.Config config = new(this);
return config.DoCommand switch
{
jitdiff.Commands.Diff => jitdiff.DiffTool.DiffCommand(config),
jitdiff.Commands.PmiDiff => jitdiff.DiffTool.DiffCommand(config),
jitdiff.Commands.List => config.ListCommand(),
jitdiff.Commands.Install => jitdiff.InstallCommand(config),
jitdiff.Commands.Uninstall => jitdiff.UninstallCommand(config),
_ => 1,
};
}
catch (Exception e)
{
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Red;

Console.Error.WriteLine("Error: " + e.Message);
Console.Error.WriteLine(e.ToString());

Console.ResetColor();
return 1;
}
}
}
}
Loading