Skip to content

Commit

Permalink
Add --inputbubbleref option to crossgen2 in order to put only part of…
Browse files Browse the repository at this point in the history
… references into version bubble (#51555)
  • Loading branch information
gbalykov committed May 14, 2021
1 parent e01ffb9 commit d71182a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class CommandLineOptions
public string HelpText;

public IReadOnlyList<string> InputFilePaths;
public IReadOnlyList<string> InputBubbleReferenceFilePaths;
public IReadOnlyList<string> UnrootedInputFilePaths;
public IReadOnlyList<string> ReferenceFilePaths;
public IReadOnlyList<string> MibcFilePaths;
Expand Down Expand Up @@ -74,6 +75,7 @@ internal class CommandLineOptions
public CommandLineOptions(string[] args)
{
InputFilePaths = Array.Empty<string>();
InputBubbleReferenceFilePaths = Array.Empty<string>();
UnrootedInputFilePaths = Array.Empty<string>();
ReferenceFilePaths = Array.Empty<string>();
MibcFilePaths = Array.Empty<string>();
Expand Down Expand Up @@ -101,6 +103,7 @@ public CommandLineOptions(string[] args)
syntax.DefineOption("Os|optimize-space", ref OptimizeSpace, SR.OptimizeSpaceOption);
syntax.DefineOption("Ot|optimize-time", ref OptimizeTime, SR.OptimizeSpeedOption);
syntax.DefineOption("inputbubble", ref InputBubble, SR.InputBubbleOption);
syntax.DefineOptionList("inputbubbleref", ref InputBubbleReferenceFilePaths, SR.InputBubbleReferenceFiles);
syntax.DefineOption("composite", ref Composite, SR.CompositeBuildMode);
syntax.DefineOption("compositekeyfile", ref CompositeKeyFile, SR.CompositeKeyFile);
syntax.DefineOption("compile-no-methods", ref CompileNoMethods, SR.CompileNoMethodsOption);
Expand Down
21 changes: 20 additions & 1 deletion src/coreclr/tools/aot/crossgen2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ internal class Program
private Dictionary<string, string> _allInputFilePaths = new Dictionary<string, string>();
private List<ModuleDesc> _referenceableModules = new List<ModuleDesc>();

private Dictionary<string, string> _inputbubblereferenceFilePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

private CompilerTypeSystemContext _typeSystemContext;
private ReadyToRunMethodLayoutAlgorithm _methodLayout;
private ReadyToRunFileLayoutAlgorithm _fileLayout;
Expand Down Expand Up @@ -128,6 +130,9 @@ private void ProcessCommandLine(string[] args)
foreach (var reference in _commandLineOptions.ReferenceFilePaths)
Helpers.AppendExpandedPaths(_referenceFilePaths, reference, false);

foreach (var reference in _commandLineOptions.InputBubbleReferenceFilePaths)
Helpers.AppendExpandedPaths(_inputbubblereferenceFilePaths, reference, false);


int alignment = _commandLineOptions.CustomPESectionAlignment;
if (alignment != 0)
Expand Down Expand Up @@ -438,14 +443,28 @@ private int Run(string[] args)
{
EcmaModule module = _typeSystemContext.GetModuleFromPath(referenceFile);
_referenceableModules.Add(module);
if (_commandLineOptions.InputBubble)
if (_commandLineOptions.InputBubble && _inputbubblereferenceFilePaths.Count == 0)
{
// In large version bubble mode add reference paths to the compilation group
// Consider bubble as large if no explicit bubble references were passed
versionBubbleModulesHash.Add(module);
}
}
catch { } // Ignore non-managed pe files
}

if (_commandLineOptions.InputBubble)
{
foreach (var referenceFile in _inputbubblereferenceFilePaths.Values)
{
try
{
EcmaModule module = _typeSystemContext.GetModuleFromPath(referenceFile);
versionBubbleModulesHash.Add(module);
}
catch { } // Ignore non-managed pe files
}
}
}

string systemModuleName = _commandLineOptions.SystemModule ?? DefaultSystemModule;
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/tools/aot/crossgen2/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
<data name="ReferenceFiles" xml:space="preserve">
<value>Reference file(s) for compilation</value>
</data>
<data name="InputBubbleReferenceFiles" xml:space="preserve">
<value>Input bubble reference file(s) to be added to bubble (any use of this option is unsupported!) </value>
</data>
<data name="ResilientOption" xml:space="preserve">
<value>Disable behavior where unexpected compilation failures cause overall compilation failure</value>
</data>
Expand Down

0 comments on commit d71182a

Please sign in to comment.