Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -21,6 +21,19 @@ namespace Mono.Linker.Steps
}
}
private static IEnumerable<TypeDefinition> EnumerateTypesAndNestedTypes (IEnumerable<TypeDefinition> types)
{
// Recursively (depth-first) yield each element in 'types' and all nested types under each element.
foreach (TypeDefinition type in types) {
yield return type;
foreach (TypeDefinition nestedType in EnumerateTypesAndNestedTypes (type.NestedTypes)) {
yield return nestedType;
}
}
}
protected override void ProcessAssembly (AssemblyDefinition assembly)
{
if ((_assemblies != null) && (!_assemblies.Contains (assembly.Name.Name))) {
@@ -30,7 +43,7 @@ namespace Mono.Linker.Steps
bool changed = false;
foreach (ModuleDefinition module in assembly.Modules) {
foreach (TypeDefinition type in module.Types) {
foreach (TypeDefinition type in EnumerateTypesAndNestedTypes (module.Types)) {
foreach (MethodDefinition method in type.Methods) {
if (method.Body != null) {
if (method.Body.InitLocals) {

File diff suppressed because it is too large Load Diff

View File

@@ -29,6 +29,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
@@ -37,7 +38,6 @@ using Mono.Cecil.PE;
namespace Mono.Linker.Steps {
public class OutputStep : BaseStep {
private static Dictionary<UInt16, TargetArchitecture> architectureMap;
private enum NativeOSOverride {
@@ -48,6 +48,12 @@ namespace Mono.Linker.Steps {
Default = 0
}
List<string> assembliesWritten;
public OutputStep () {
assembliesWritten = new List<string> ();
}
static TargetArchitecture CalculateArchitecture (TargetArchitecture readyToRunArch)
{
if (architectureMap == null) {
@@ -74,6 +80,15 @@ namespace Mono.Linker.Steps {
Tracer.Finish ();
}
protected override void EndProcess ()
{
if (Context.AssemblyListFile != null) {
using (var w = File.CreateText (Context.AssemblyListFile)) {
w.WriteLine ("[" + String.Join (", ", assembliesWritten.Select (a => "\"" + a + "\"").ToArray ()) + "]");
}
}
}
void CheckOutputDirectory ()
{
if (Directory.Exists (Context.OutputDirectory))
@@ -127,12 +142,14 @@ namespace Mono.Linker.Steps {
Context.Tracer.AddDependency (assembly);
WriteAssembly (assembly, directory);
CopySatelliteAssembliesIfNeeded (assembly, directory);
assembliesWritten.Add (GetOriginalAssemblyFileInfo (assembly).Name);
break;
case AssemblyAction.Copy:
Context.Tracer.AddDependency (assembly);
CloseSymbols (assembly);
CopyAssembly (assembly, directory);
CopySatelliteAssembliesIfNeeded (assembly, directory);
assembliesWritten.Add (GetOriginalAssemblyFileInfo (assembly).Name);
break;
case AssemblyAction.Delete:
CloseSymbols (assembly);

View File

@@ -67,6 +67,10 @@ namespace Mono.Linker.Steps
}
}
}
if (type.Namespace == "System.Reflection.Emit") {
foreach (var method in type.Methods)
Annotations.SetAction (method, MethodAction.ConvertToThrow);
}
}
if (FeatureGlobalization)

View File

@@ -242,7 +242,7 @@ namespace Mono.Linker.Steps {
// type forwarders to deleted assembly (facade) when
// facade assemblies are not kept. For that reason we need to
// rewrite the copy to save to update the scopes not to point
// forwardning assembly (facade).
// forwarding assembly (facade).
//
// foo.dll -> facade.dll -> lib.dll
// copy | copy (delete) | link
@@ -281,7 +281,14 @@ namespace Mono.Linker.Steps {
if (tr.IsWindowsRuntimeProjection)
continue;
var td = tr.Resolve ();
TypeDefinition td;
try {
td = tr.Resolve ();
} catch (AssemblyResolutionException) {
// Don't crash on unresolved assembly
continue;
}
// at this stage reference might include things that can't be resolved
// and if it is (resolved) it needs to be kept only if marked (#16213)
if (td == null || !Annotations.IsMarked (td))
@@ -414,6 +421,10 @@ namespace Mono.Linker.Steps {
static void UpdateTypeScope (TypeReference type, AssemblyDefinition assembly)
{
// Can't update the scope of windows runtime projections
if (type.IsWindowsRuntimeProjection)
return;
if (type is GenericInstanceType git && git.HasGenericArguments) {
UpdateTypeScope (git.ElementType, assembly);
foreach (var ga in git.GenericArguments)

View File

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

View File

@@ -262,6 +262,10 @@ namespace Mono.Linker {
context.DeterministicOutput = true;
p.RemoveStep (typeof (RegenerateGuidStep));
continue;
case "--output-assemblylist":
context.AssemblyListFile = GetParam ();
continue;
}
switch (token [2]) {
@@ -402,6 +406,9 @@ namespace Mono.Linker {
case "unreachablebodies":
context.DisabledOptimizations |= CodeOptimizations.UnreachableBodies;
break;
case "unusedinterfaces":
context.DisabledOptimizations |= CodeOptimizations.UnusedInterfaces;
break;
}
}
}
@@ -584,7 +591,8 @@ namespace Mono.Linker {
Console.WriteLine (" --disable-opt <name> Disable one of the default optimizations");
Console.WriteLine (" beforefieldinit: Unused static fields are removed if there is no static ctor");
Console.WriteLine (" overrideremoval: Overrides of virtual methods on types that are never instantiated are removed");
Console.WriteLine (" unreachablebodies: Instance methods that are marked but can never be entered are converted to throws");
Console.WriteLine (" unreachablebodies: Instance methods that are marked but not executed are converted to throws");
Console.WriteLine (" unusedinterfaces: Removes interface types from declaration when not used");
Console.WriteLine (" --enable-opt <name> Enable one of the non-default optimizations");
Console.WriteLine (" clearinitlocals: Remove initlocals");
Console.WriteLine (" --exclude-feature <name> Any code which has a feature <name> in linked assemblies will be removed");

View File

@@ -155,6 +155,8 @@ namespace Mono.Linker {
public bool AddReflectionAnnotations { get; set; }
public string AssemblyListFile { get; set; }
public LinkContext (Pipeline pipeline)
: this (pipeline, new AssemblyResolver ())
{
@@ -430,6 +432,11 @@ namespace Mono.Linker {
/// <summary>
/// Option to clear the initlocals flag on methods
/// </summary>
ClearInitLocals = 1 << 3
ClearInitLocals = 1 << 3,
/// <summary>
/// Option to remove .interfaceimpl for interface types that are not used
/// </summary>
UnusedInterfaces = 1 << 4,
}
}

View File

@@ -329,7 +329,7 @@ namespace Mono.Linker {
void ProcessInterfaces (XPathNavigator nav)
{
ProcessChildren (nav, "intefaces//interface", new OnChildren (OnInterface));
ProcessChildren (nav, "interfaces//interface", new OnChildren (OnInterface));
}
void ProcessFields (XPathNavigator nav)

View File

@@ -1,35 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Condition=" $(Configuration.StartsWith('illink')) ">
<AssemblyName>illink</AssemblyName>
<Description>IL Linker</Description>
<DefineConstants>$(DefineConstants);FEATURE_ILLINK</DefineConstants>
<!-- net46 build is disabled until cecil uses SDK-style projects. -->
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(MSBuildRuntimeType)' == 'Core' And '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" ! $(Configuration.StartsWith('illink')) ">
<AssemblyName>monolinker</AssemblyName>
<AssemblyTitle>Mono.Linker</AssemblyTitle>
<Description>Mono CIL Linker</Description>
<TargetFrameworks>net471</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>Mono</RootNamespace>
<Copyright>(C) 2006, Jb Evain</Copyright>
<Version>0.2.0.0</Version>
<Configurations>Debug;Release;illink_Debug;illink_Release</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" $(Configuration.EndsWith('Debug')) ">
<DebugSymbols Condition=" '$(DebugSymbols)' == '' ">true</DebugSymbols>
<Optimize Condition=" '$(Optimize)' == '' ">false</Optimize>
<PropertyGroup Condition="$(Configuration.StartsWith('illink'))">
<AssemblyName>illink</AssemblyName>
<Description>IL Linker</Description>
<DefineConstants>$(DefineConstants);FEATURE_ILLINK</DefineConstants>
<!-- net46 build is disabled until cecil uses SDK-style projects. -->
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(MSBuildRuntimeType)' == 'Core' And '$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" $(Configuration.EndsWith('Release')) ">
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
<PropertyGroup Condition="!$(Configuration.StartsWith('illink'))">
<AssemblyName>monolinker</AssemblyName>
<AssemblyTitle>Mono.Linker</AssemblyTitle>
<Description>Mono CIL Linker</Description>
<TargetFrameworks>net471</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.EndsWith('Debug'))">
<DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
<Optimize Condition="'$(Optimize)' == ''">false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.EndsWith('Release'))">
<Optimize Condition="'$(Optimize)' == ''">true</Optimize>
</PropertyGroup>
<ItemGroup>
@@ -44,7 +45,7 @@
<Target Name="AddRuntimeDependenciesToContent"
BeforeTargets="GetCopyToOutputDirectoryItems"
DependsOnTargets="GenerateBuildDependencyFile;GenerateBuildRuntimeConfigurationFiles"
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<ItemGroup>
<ContentWithTargetPath Include="$(ProjectDepsFilePath)" CopyToOutputDirectory="PreserveNewest" TargetPath="$(ProjectDepsFileName)" />
<ContentWithTargetPath Include="$(ProjectRuntimeConfigFilePath)" CopyToOutputDirectory="PreserveNewest" TargetPath="$(ProjectRuntimeConfigFileName)" />