Add --inputbubbleref option to crossgen2 in order to put only part of references...
authorGleb Balykov <g.balykov@samsung.com>
Fri, 14 May 2021 23:36:23 +0000 (02:36 +0300)
committerGitHub <noreply@github.com>
Fri, 14 May 2021 23:36:23 +0000 (16:36 -0700)
src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs
src/coreclr/tools/aot/crossgen2/Program.cs
src/coreclr/tools/aot/crossgen2/Properties/Resources.resx

index 8933085..573b1eb 100644 (file)
@@ -16,6 +16,7 @@ namespace ILCompiler
         public string HelpText;
 
         public IReadOnlyList<string> InputFilePaths;
+        public IReadOnlyList<string> InputBubbleReferenceFilePaths;
         public IReadOnlyList<string> UnrootedInputFilePaths;
         public IReadOnlyList<string> ReferenceFilePaths;
         public IReadOnlyList<string> MibcFilePaths;
@@ -74,6 +75,7 @@ namespace ILCompiler
         public CommandLineOptions(string[] args)
         {
             InputFilePaths = Array.Empty<string>();
+            InputBubbleReferenceFilePaths = Array.Empty<string>();
             UnrootedInputFilePaths = Array.Empty<string>();
             ReferenceFilePaths = Array.Empty<string>();
             MibcFilePaths = Array.Empty<string>();
@@ -101,6 +103,7 @@ namespace ILCompiler
                 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);
index b5d93d1..2f84f6f 100644 (file)
@@ -36,6 +36,8 @@ namespace ILCompiler
         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;
@@ -128,6 +130,9 @@ namespace ILCompiler
             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)
@@ -438,14 +443,28 @@ namespace ILCompiler
                     {
                         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;
index bb6bcec..084138e 100644 (file)
   <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>