[mono/mono] c5fbe7ae: [linker]: Also reference all type-references for LinkAction.Link and Save.
| Newsgroups | gmane.comp.gnome.mono.patches |
|---|---|
| Message-ID | <00000141f098abc2-6f15e742-4375-45a6-ae14-2f8b37eb07d7-000000@email.amazonses.com> |
Branch: refs/heads/mtvs-1.8-series
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/65aefd97497e...c5fbe7ae039b
Commit: c5fbe7ae039bc0971a382821f9ba5ecbc55ac489
Author: Martin Baulig <[email protected]> (baulig)
Date: 2013-10-25 17:09:17 GMT
URL: https://github.com/mono/mono/commit/c5fbe7ae039bc0971a382821f9ba5ecbc55ac489
[linker]: Also reference all type-references for LinkAction.Link and Save.
Changed paths:
M mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
Modified: 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,21 +103,38 @@ void SweepReferences (AssemblyDefinition assembly, AssemblyDefinition target)
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);
- // note: we only enter here (Copy->Save once) so we nned to do the complete job
- 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;
- }
+ 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)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches