diff options
author | Martin Baulig <martin.baulig@xamarin.com> | 2013-10-25 17:15:18 +0400 |
---|---|---|
committer | Martin Baulig <martin.baulig@xamarin.com> | 2013-10-25 17:17:02 +0400 |
commit | c29ac46c408aa2ae588548fa36a0aa9bf0b01014 (patch) | |
tree | 8ddfb2ac7f943acfbfa589e12b8fec341dc90f14 /mcs | |
parent | f16333347399978cc1b2643a5c79c61996503c7e (diff) |
[linker]: Also reference all type-references for LinkAction.Link and Save.
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs b/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs index 5cea341b099..20f06f3bb58 100644 --- a/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs +++ b/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs @@ -37,6 +37,7 @@ namespace Mono.Linker.Steps { public class SweepStep : BaseStep { AssemblyDefinition [] assemblies; + HashSet<AssemblyDefinition> resolvedTypeReferences; protected override void Process () { @@ -102,15 +103,38 @@ namespace Mono.Linker.Steps { references.RemoveAt (i); // Removing the reference does not mean it will be saved back to disk! // That depends on the AssemblyAction set for the `assembly` - if (Annotations.GetAction (assembly) == AssemblyAction.Copy) { + switch (Annotations.GetAction (assembly)) { + case AssemblyAction.Copy: // Copy means even if "unlinked" we still want that assembly to be saved back // to disk (OutputStep) without the (removed) reference Annotations.SetAction (assembly, AssemblyAction.Save); + ResolveAllTypeReferences (assembly); + break; + + case AssemblyAction.Save: + case AssemblyAction.Link: + ResolveAllTypeReferences (assembly); + break; } return; } } + void ResolveAllTypeReferences (AssemblyDefinition assembly) + { + if (resolvedTypeReferences == null) + resolvedTypeReferences = new HashSet<AssemblyDefinition> (); + if (resolvedTypeReferences.Contains (assembly)) + return; + resolvedTypeReferences.Add (assembly); + + foreach (TypeReference tr in assembly.MainModule.GetTypeReferences ()) { + var td = tr.Resolve (); + // at this stage reference might include things that can't be resolved + tr.Scope = td == null ? null : assembly.MainModule.Import (td).Scope; + } + } + void SweepType (TypeDefinition type) { if (type.HasFields) |