Skip to content

Commit ce78f97

Browse files
authored
Improve crossgen2 --help layout (#88544)
1 parent 045b526 commit ce78f97

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,6 @@ public static IEnumerable<Action<HelpContext>> GetExtendedHelp(HelpContext _)
319319

320320
foreach (string arch in ValidArchitectures)
321321
{
322-
Console.Write(arch);
323-
Console.Write(": ");
324-
325322
TargetArchitecture targetArch = Helpers.GetTargetArchitecture(arch);
326323
bool first = true;
327324
foreach (var instructionSet in Internal.JitInterface.InstructionSetFlags.ArchitectureToValidInstructionSets(targetArch))
@@ -331,6 +328,8 @@ public static IEnumerable<Action<HelpContext>> GetExtendedHelp(HelpContext _)
331328
{
332329
if (first)
333330
{
331+
Console.Write(arch);
332+
Console.Write(": ");
334333
first = false;
335334
}
336335
else
@@ -341,6 +340,8 @@ public static IEnumerable<Action<HelpContext>> GetExtendedHelp(HelpContext _)
341340
}
342341
}
343342

343+
if (first) continue; // no instruction-set found for this architecture
344+
344345
Console.WriteLine();
345346
}
346347

src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal class Crossgen2RootCommand : CliRootCommand
4040
public CliOption<bool> OptimizeTime { get; } =
4141
new("--optimize-time", "--Ot") { Description = SR.OptimizeSpeedOption };
4242
public CliOption<TypeValidationRule> TypeValidation { get; } =
43-
new("--type-validation") { DefaultValueFactory = _ => TypeValidationRule.Automatic, Description = SR.TypeValidation };
43+
new("--type-validation") { DefaultValueFactory = _ => TypeValidationRule.Automatic, Description = SR.TypeValidation, HelpName = "arg" };
4444
public CliOption<bool> InputBubble { get; } =
4545
new("--inputbubble") { Description = SR.InputBubbleOption };
4646
public CliOption<Dictionary<string, string>> InputBubbleReferenceFilePaths { get; } =
@@ -126,9 +126,9 @@ internal class Crossgen2RootCommand : CliRootCommand
126126
public CliOption<string> NonLocalGenericsModule { get; } =
127127
new("--non-local-generics-module") { DefaultValueFactory = _ => string.Empty, Description = SR.NonLocalGenericsModule };
128128
public CliOption<ReadyToRunMethodLayoutAlgorithm> MethodLayout { get; } =
129-
new("--method-layout") { CustomParser = MakeReadyToRunMethodLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunMethodLayoutAlgorithm, Description = SR.MethodLayoutOption };
129+
new("--method-layout") { CustomParser = MakeReadyToRunMethodLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunMethodLayoutAlgorithm, Description = SR.MethodLayoutOption, HelpName = "arg" };
130130
public CliOption<ReadyToRunFileLayoutAlgorithm> FileLayout { get; } =
131-
new("--file-layout") { CustomParser = MakeReadyToRunFileLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunFileLayoutAlgorithm, Description = SR.FileLayoutOption };
131+
new("--file-layout") { CustomParser = MakeReadyToRunFileLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunFileLayoutAlgorithm, Description = SR.FileLayoutOption, HelpName = "arg" };
132132
public CliOption<bool> VerifyTypeAndFieldLayout { get; } =
133133
new("--verify-type-and-field-layout") { Description = SR.VerifyTypeAndFieldLayoutOption };
134134
public CliOption<string> CallChainProfileFile { get; } =
@@ -301,13 +301,19 @@ public static IEnumerable<Action<HelpContext>> GetExtendedHelp(HelpContext _)
301301
Console.WriteLine();
302302
Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--targetarch", String.Join("', '", ValidArchitectures), Helpers.GetTargetArchitecture(null).ToString().ToLowerInvariant()));
303303
Console.WriteLine();
304+
Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--type-validation", String.Join("', '", Enum.GetNames<TypeValidationRule>()), nameof(TypeValidationRule.Automatic)));
305+
Console.WriteLine();
306+
307+
Console.WriteLine(SR.CrossModuleInliningExtraHelp);
308+
Console.WriteLine();
309+
Console.WriteLine(String.Format(SR.LayoutOptionExtraHelp, "--method-layout", String.Join("', '", Enum.GetNames<ReadyToRunMethodLayoutAlgorithm>())));
310+
Console.WriteLine();
311+
Console.WriteLine(String.Format(SR.LayoutOptionExtraHelp, "--file-layout", String.Join("', '", Enum.GetNames<ReadyToRunFileLayoutAlgorithm>())));
312+
Console.WriteLine();
304313

305314
Console.WriteLine(SR.InstructionSetHelp);
306315
foreach (string arch in ValidArchitectures)
307316
{
308-
Console.Write(arch);
309-
Console.Write(": ");
310-
311317
TargetArchitecture targetArch = Helpers.GetTargetArchitecture(arch);
312318
bool first = true;
313319
foreach (var instructionSet in Internal.JitInterface.InstructionSetFlags.ArchitectureToValidInstructionSets(targetArch))
@@ -317,6 +323,8 @@ public static IEnumerable<Action<HelpContext>> GetExtendedHelp(HelpContext _)
317323
{
318324
if (first)
319325
{
326+
Console.Write(arch);
327+
Console.Write(": ");
320328
first = false;
321329
}
322330
else
@@ -327,6 +335,8 @@ public static IEnumerable<Action<HelpContext>> GetExtendedHelp(HelpContext _)
327335
}
328336
}
329337

338+
if (first) continue; // no instruction-set found for this architecture
339+
330340
Console.WriteLine();
331341
}
332342

src/coreclr/tools/aot/crossgen2/Properties/Resources.resx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,13 @@
313313
<value>Error: multiple input files are only supported in composite build mode: {0}</value>
314314
</data>
315315
<data name="MethodLayoutOption" xml:space="preserve">
316-
<value>Layout algorithm used by profile-driven optimization for arranging methods in a file: DefaultSort, ExclusiveWeight, HotCold, or HotWarmCold). The default value is DefaultSort, which indicates that complex layout is disabled.</value>
316+
<value>Layout algorithm used by profile-driven optimization for arranging methods in a file.</value>
317317
</data>
318318
<data name="FileLayoutOption" xml:space="preserve">
319-
<value>Layout algorithm used by profile-driven optimization for arranging non-method contents in a file: DefaultSort or MethodOrder. The default value is DefaultSort, which indicates that complex layout is disabled.</value>
319+
<value>Layout algorithm used by profile-driven optimization for arranging non-method contents in a file.</value>
320+
</data>
321+
<data name="LayoutOptionExtraHelp" xml:space="preserve">
322+
<value>Note for {0}: Valid options are {1}. The default value is DefaultSort, which indicates that complex layout is disabled.</value>
320323
</data>
321324
<data name="CompositeRootPath" xml:space="preserve">
322325
<value>Logical root folder for composite builds; defaults to directory of 1st input file.</value>
@@ -382,13 +385,19 @@
382385
<value>Hexadecimal value to set target PE-file ImageBase field</value>
383386
</data>
384387
<data name="CrossModuleInlining" xml:space="preserve">
385-
<value>Allow inclusion of code from the specified module into the module being compiled. In addition to specifying an assembly by name, the special value of "*" is recognized as indicating that code from all modules may be included. Any module specified in this way MUST be loadable from the first moment the R2R module is loaded, as loads of these modules may be triggered unpredictably.</value>
388+
<value>Allow inclusion of code from the specified module into the module being compiled.</value>
389+
</data>
390+
<data name="CrossModuleInliningExtraHelp" xml:space="preserve">
391+
<value>Note for --opt-cross-module: In addition to specifying an assembly by name, the special value of "*" is recognized as indicating that code from all modules may be included. Any module specified in this way MUST be loadable from the first moment the R2R module is loaded, as loads of these modules may be triggered unpredictably.</value>
386392
</data>
387393
<data name="AsyncModuleOptimization" xml:space="preserve">
388394
<value>Attempt to compile as much async infrastructure as possible for async methods. Defaults to enabled. To disable, specify false to this flag explicitly.</value>
389395
</data>
390396
<data name="NonLocalGenericsModule" xml:space="preserve">
391-
<value>Specify the module which is permitted to contain generics defined or instantiated in any other module. Specify "*" to indicate that any module may hold arbitrary generics.</value>
397+
<value>Specify "*" to indicate that any module may hold arbitrary generics.</value>
398+
</data>
399+
<data name="NonLocalGenericsModuleExtraHelp" xml:space="preserve">
400+
<value>Note for --non-local-generics-module: Specify "*" to indicate that any module may hold arbitrary generics.</value>
392401
</data>
393402
<data name="ErrorNonLocalGenericsModule" xml:space="preserve">
394403
<value>"{0}" was specified to the --non-local-generics-module switch, but was not in the set of modules associated with the compile</value>
@@ -414,4 +423,4 @@
414423
<data name="GenericCycleDepthCutoff" xml:space="preserve">
415424
<value>Number of nested occurrences of a potentially cyclic generic type to cut off</value>
416425
</data>
417-
</root>
426+
</root>

0 commit comments

Comments
 (0)