diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 84df31ff5e02..c7d2f8e5c56b 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -395,7 +395,7 @@ void AutoConfigureIOS () IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); - IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "dotnet", "iOS", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, Ignore = true }); + IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "dotnet", "iOS", "link all.csproj"))) { Configurations = new string [] { "Debug" /*, "Release" */ }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "dotnet", "iOS", "link sdk.csproj"))) { Configurations = new string [] { "Debug" /*, "Release" */ }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); diff --git a/tools/common/Application.cs b/tools/common/Application.cs index 29bea63e147e..5984998893af 100644 --- a/tools/common/Application.cs +++ b/tools/common/Application.cs @@ -707,6 +707,7 @@ public void RunRegistrar () public IEnumerable Abis { get { return abis; } + set { abis = new List (value); } } public bool IsArchEnabled (Abi arch) diff --git a/tools/dotnet-linker/Compat.cs b/tools/dotnet-linker/Compat.cs index 03bada023a92..36ca00d6b55b 100644 --- a/tools/dotnet-linker/Compat.cs +++ b/tools/dotnet-linker/Compat.cs @@ -1,6 +1,7 @@ // Compat.cs: might not be ideal but it eases code sharing with existing code during the initial implementation. using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; using Mono.Cecil; using Mono.Linker; @@ -160,9 +161,14 @@ public static IEnumerable GetAssemblies (this LinkContext co { return LinkerConfiguration.GetInstance (context).Assemblies; } + + static ConditionalWeakTable>> custom_annotations = new ConditionalWeakTable>> (); public static Dictionary GetCustomAnnotations (this AnnotationStore self, string name) { - throw new NotImplementedException (); + var store = custom_annotations.GetOrCreateValue (self); + if (!store.TryGetValue (name, out var dict)) + store [name] = dict = new Dictionary (); + return dict; } } } diff --git a/tools/dotnet-linker/LinkerConfiguration.cs b/tools/dotnet-linker/LinkerConfiguration.cs index 1e59a0cc38e0..361147523e49 100644 --- a/tools/dotnet-linker/LinkerConfiguration.cs +++ b/tools/dotnet-linker/LinkerConfiguration.cs @@ -208,6 +208,10 @@ public static LinkerConfiguration GetInstance (LinkContext context) Application.DeploymentTarget = DeploymentTarget; Application.SdkVersion = SdkVersion; + DerivedLinkContext.Target = Target; + Target.Abis = Abis; + Application.Abis = Abis; + switch (Platform) { case ApplePlatform.iOS: case ApplePlatform.TVOS: diff --git a/tools/dotnet-linker/SetupStep.cs b/tools/dotnet-linker/SetupStep.cs index f12f054ffc17..1c121fe05e3f 100644 --- a/tools/dotnet-linker/SetupStep.cs +++ b/tools/dotnet-linker/SetupStep.cs @@ -55,6 +55,7 @@ protected override void Process () // [assembly: LinkSafe] attributes, which means we treat them as sdk assemblies and those may have // Preserve attributes. prelink_substeps.Add (new ApplyPreserveAttribute ()); + prelink_substeps.Add (new OptimizeGeneratedCodeSubStep ()); prelink_substeps.Add (new MarkNSObjects ()); prelink_substeps.Add (new PreserveSmartEnumConversionsSubStep ()); } diff --git a/tools/dotnet-linker/dotnet-linker.csproj b/tools/dotnet-linker/dotnet-linker.csproj index 30780ebb4ac8..cd869961f63d 100644 --- a/tools/dotnet-linker/dotnet-linker.csproj +++ b/tools/dotnet-linker/dotnet-linker.csproj @@ -101,6 +101,9 @@ external\tools\linker\CustomSymbolWriter.cs + + external\tools\linker\CoreOptimizeGeneratedCode.cs + external\src\ObjCRuntime\Registrar.cs @@ -164,6 +167,12 @@ external\mono-archive\Linker\I18nAssemblies.cs + + mono-archive\Linker\MethodDefinitionExtensions.cs + + + mono-archive\Linker\Linker\TypeReferenceExtensions.cs + external\mono-archive\Mono.Tuner\CecilRocks.cs diff --git a/tools/linker/CoreOptimizeGeneratedCode.cs b/tools/linker/CoreOptimizeGeneratedCode.cs index cb2c422de381..93754c2b00e3 100644 --- a/tools/linker/CoreOptimizeGeneratedCode.cs +++ b/tools/linker/CoreOptimizeGeneratedCode.cs @@ -573,7 +573,7 @@ protected void EliminateDeadCode (MethodDefinition caller) } } } -#if TRACE +#if false Console.WriteLine ($"{caller.FullName}:"); for (int i = 0; i < reachable.Length; i++) { Console.WriteLine ($"{(reachable [i] ? " " : "- ")} {instructions [i]}");