Imported Upstream version 6.8.0.73

Former-commit-id: d18deab1b47cfd3ad8cba82b3f37d00eec2170af
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-12-10 18:00:56 +00:00
parent bceda29824
commit 73ee7591e8
1043 changed files with 16271 additions and 22080 deletions

View File

@@ -95,6 +95,8 @@ namespace ILLink.Tasks
/// ToolTask implementation
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
protected override string ToolName => Path.GetFileName (DotNetPath);

File diff suppressed because it is too large Load Diff

View File

@@ -103,7 +103,12 @@ namespace Mono.Linker.Steps {
}
}
assembly.Write (GetAssemblyFileName (assembly, directory), writerParameters);
string outputName = GetAssemblyFileName (assembly, directory);
try {
assembly.Write (outputName, writerParameters);
} catch (Exception e) {
throw new OutputException ($"Failed to write '{outputName}", e);
}
}
void OutputAssembly (AssemblyDefinition assembly)
@@ -121,11 +126,13 @@ namespace Mono.Linker.Steps {
case AssemblyAction.AddBypassNGen:
Context.Tracer.AddDependency (assembly);
WriteAssembly (assembly, directory);
CopySatelliteAssembliesIfNeeded (assembly, directory);
break;
case AssemblyAction.Copy:
Context.Tracer.AddDependency (assembly);
CloseSymbols (assembly);
CopyAssembly (assembly, directory);
CopySatelliteAssembliesIfNeeded (assembly, directory);
break;
case AssemblyAction.Delete:
CloseSymbols (assembly);
@@ -176,6 +183,28 @@ namespace Mono.Linker.Steps {
return parameters;
}
void CopySatelliteAssembliesIfNeeded (AssemblyDefinition assembly, string directory)
{
if (!Annotations.ProcessSatelliteAssemblies)
return;
FileInfo original = GetOriginalAssemblyFileInfo (assembly);
string resourceFile = GetAssemblyResourceFileName (original.FullName);
foreach (var subDirectory in Directory.EnumerateDirectories (original.DirectoryName)) {
var satelliteAssembly = Path.Combine (subDirectory, resourceFile);
if (!File.Exists (satelliteAssembly))
continue;
string cultureName = subDirectory.Substring (subDirectory.LastIndexOf (Path.DirectorySeparatorChar) + 1);
string culturePath = Path.Combine (directory, cultureName);
Directory.CreateDirectory (culturePath);
File.Copy (satelliteAssembly, Path.Combine (culturePath, resourceFile), true);
}
}
void CopyConfigFileIfNeeded (AssemblyDefinition assembly, string directory)
{
string config = GetConfigFile (GetOriginalAssemblyFileInfo (assembly).FullName);
@@ -190,6 +219,11 @@ namespace Mono.Linker.Steps {
File.Copy (config, GetConfigFile (GetAssemblyFileName (assembly, directory)), true);
}
static string GetAssemblyResourceFileName (string assembly)
{
return Path.GetFileNameWithoutExtension (assembly) + ".resources.dll";
}
static string GetConfigFile (string assembly)
{
return assembly + ".config";

View File

@@ -64,6 +64,19 @@ namespace Mono.Linker.Steps {
return tr.Name == "PreserveDependencyAttribute" && tr.Namespace == "System.Runtime.CompilerServices";
}
public static bool HasPreserveDependencyAttribute (MethodDefinition method)
{
if (!method.HasCustomAttributes)
return false;
foreach (var ca in method.CustomAttributes) {
if (IsPreserveDependencyAttribute (ca.AttributeType))
return true;
}
return false;
}
void ProcessPreserveDependencyAttribute (Collection<CustomAttribute> attributes)
{
foreach (var ca in attributes) {

View File

@@ -104,7 +104,8 @@ namespace Mono.Linker.Steps {
{
while (iterator.MoveNext ()) {
AssemblyDefinition assembly = GetAssembly (context, GetAssemblyName (iterator.Current));
ProcessAssembly (assembly, iterator);
if (assembly != null)
ProcessAssembly (assembly, iterator);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -60,6 +60,8 @@ namespace Mono.Linker {
public AnnotationStore (LinkContext context) => this.context = context;
public bool ProcessSatelliteAssemblies { get; set; }
protected Tracer Tracer {
get {
return context.Tracer;

View File

@@ -121,8 +121,7 @@ namespace Mono.Linker {
} catch (AssemblyResolutionException) {
if (!_ignoreUnresolved)
throw;
_context.LogMessage ($"warning: unresolved assembly {name.Name}");
_context.LogMessage ($"Ignoring unresolved assembly '{name.Name}'.");
if (_unresolvedAssemblies == null)
_unresolvedAssemblies = new HashSet<string> ();
_unresolvedAssemblies.Add (name.Name);

View File

@@ -231,6 +231,10 @@ namespace Mono.Linker {
context.KeepTypeForwarderOnlyAssemblies = bool.Parse (GetParam ());
continue;
case "--keep-dep-attributes":
context.KeepDependencyAttributes = bool.Parse (GetParam ());
continue;
case "--ignore-descriptors":
ignoreDescriptors = bool.Parse (GetParam ());
continue;
@@ -559,13 +563,14 @@ namespace Mono.Linker {
Console.WriteLine (" --about About the {0}", _linker);
Console.WriteLine (" --verbose Log messages indicating progress and warnings");
Console.WriteLine (" --version Print the version number of the {0}", _linker);
Console.WriteLine (" @<file> Read response file for more options");
Console.WriteLine ();
Console.WriteLine ("Actions");
Console.WriteLine (" -c <action> Action on the core assemblies. Defaults to 'skip'");
Console.WriteLine (" copy: Copy the files into the output directory");
Console.WriteLine (" copyused: Copy the files only when anything from the assembly is used");
Console.WriteLine (" link: Link the assembly");
Console.WriteLine (" -c <action> Action on the framework assemblies. Defaults to 'skip'");
Console.WriteLine (" copy: Copy the assembly into the output (it can be updated when any of its dependencies is removed)");
Console.WriteLine (" copyused: Same as copy but only for assemblies which are needed");
Console.WriteLine (" link: Remove any ununsed code or metadata from the assembly");
Console.WriteLine (" skip: Do not process the assembly");
Console.WriteLine (" addbypassngen: Add BypassNGenAttribute to unused methods");
Console.WriteLine (" addbypassngenused: Same as addbypassngen but unused assemblies are removed");
@@ -590,6 +595,7 @@ namespace Mono.Linker {
Console.WriteLine (" globalization: Globalization data and globalization behavior");
Console.WriteLine (" --ignore-descriptors Skips reading embedded descriptors (short -z). Defaults to false");
Console.WriteLine (" --keep-facades Keep assemblies with type-forwarders (short -t). Defaults to false");
Console.WriteLine (" --keep-dep-attributes Keep attributes used for manual dependency tracking. Defaults to false");
Console.WriteLine (" --new-mvid Generate a new guid for each linked assembly (short -g). Defaults to true");
Console.WriteLine (" --skip-unresolved Ignore unresolved types, methods, and assemblies. Defaults to false");
Console.WriteLine (" --strip-resources Remove XML descriptor resources for linked assemblies. Defaults to true");

View File

@@ -17,5 +17,14 @@ namespace Mono.Linker
return true;
}
public static bool IsSatelliteAssemblyMarker (MethodDefinition method)
{
if (!method.IsConstructor || method.IsStatic)
return false;
var declaringType = method.DeclaringType;
return declaringType.Name == "ResourceManager" && declaringType.Namespace == "System.Resources";
}
}
}

View File

@@ -113,6 +113,8 @@ namespace Mono.Linker {
public bool KeepUsedAttributeTypesOnly { get; set; }
public bool KeepDependencyAttributes { get; set; }
public bool StripResources { get; set; }
public System.Collections.IDictionary Actions {
@@ -285,6 +287,8 @@ namespace Mono.Linker {
public virtual ICollection<AssemblyDefinition> ResolveReferences (AssemblyDefinition assembly)
{
List<AssemblyDefinition> references = new List<AssemblyDefinition> ();
if (assembly == null)
return references;
foreach (AssemblyNameReference reference in assembly.MainModule.AssemblyReferences) {
AssemblyDefinition definition = Resolve (reference);
if (definition != null)

View File

@@ -0,0 +1,17 @@
using System;
namespace Mono.Linker
{
public class OutputException : Exception
{
public OutputException (string message)
: base (message)
{
}
public OutputException (string message, Exception innerException)
: base (message, innerException)
{
}
}
}

View File

@@ -231,5 +231,11 @@ namespace Mono.Linker
throw new NotImplementedException ();
}
public static bool IsTypeOf (this TypeReference type, string ns, string name)
{
return type.Name == name
&& type.Namespace == ns;
}
}
}

View File

@@ -44,10 +44,6 @@ namespace Mono.Tuner {
get { return context.Annotations; }
}
internal Tracer Tracer {
get { return context.Tracer; }
}
public abstract SubStepTargets Targets { get; }
public virtual void Initialize (LinkContext context)
@@ -96,6 +92,8 @@ namespace Mono.Tuner {
List<ISubStep> on_properties;
List<ISubStep> on_events;
Tracer tracer;
public void Add (ISubStep substep)
{
substeps.Add (substep);
@@ -103,11 +101,25 @@ namespace Mono.Tuner {
public void Process (LinkContext context)
{
tracer = context.Tracer;
InitializeSubSteps (context);
BrowseAssemblies (context.GetAssemblies ());
}
void Push (ISubStep subStep)
{
if (tracer != null)
tracer.Push (subStep);
}
void Pop ()
{
if (tracer != null)
tracer.Pop ();
}
static bool HasSubSteps (List<ISubStep> substeps)
{
return substeps != null && substeps.Count > 0;
@@ -186,49 +198,55 @@ namespace Mono.Tuner {
void DispatchAssembly (AssemblyDefinition assembly)
{
foreach (var substep in on_assemblies) {
var bs = substep as BaseSubStep;
if (bs != null)
bs.Tracer.Push (substep);
Push (substep);
substep.ProcessAssembly (assembly);
if (bs != null)
bs.Tracer.Pop ();
Pop ();
}
}
void DispatchType (TypeDefinition type)
{
foreach (var substep in on_types) {
var bs = substep as BaseSubStep;
if (bs != null)
bs.Tracer.Push (substep);
Push (substep);
substep.ProcessType (type);
if (bs != null)
bs.Tracer.Pop ();
Pop ();
}
}
void DispatchField (FieldDefinition field)
{
foreach (var substep in on_fields)
foreach (var substep in on_fields) {
Push (substep);
substep.ProcessField (field);
Pop ();
}
}
void DispatchMethod (MethodDefinition method)
{
foreach (var substep in on_methods)
foreach (var substep in on_methods) {
Push (substep);
substep.ProcessMethod (method);
Pop ();
}
}
void DispatchProperty (PropertyDefinition property)
{
foreach (var substep in on_properties)
foreach (var substep in on_properties) {
Push (substep);
substep.ProcessProperty (property);
Pop ();
}
}
void DispatchEvent (EventDefinition @event)
{
foreach (var substep in on_events)
foreach (var substep in on_events) {
Push (substep);
substep.ProcessEvent (@event);
Pop ();
}
}
void InitializeSubSteps (LinkContext context)