From 85fe6340f60849f5344b7b9f4bf712b232f0e1e1 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 23 Feb 2021 07:49:09 +0100 Subject: [PATCH] Bump .NET to 6.0.100-preview.2.21114.3. (#10666) * Bump .NET to 6.0.100-preview.2.21114.3. * [dotnet-linker] Several steps are now gone, so load our custom step before the new first step (MarkStep). * [dotnet-linker] Dump the current steps if we fail to call InsertBefore/InsertAfter. * [dotnet-linker] Load the CollectAssembliesStep as the first step, and make it load every assembly. * [dotnet] Set InvariantGlobalization=true because that's the only thing .NET supports for now. * [dotnet-linker] Use recommended workaround for linker's inability to do load assemblies in custom step. * [tests] Bump version of MSBuild.StructuredLogger to get support for new log version. Otherwise this happens in tests that read binary logs: System.NotSupportedException : Unsupported log file format. Latest supported version is 9, the log file has version 10. * [introspection] Ignore P/Invokes to QCall for LogThreadPool* P/Invokes. * [dotnet-linker] Inject a dummy implementation of mono_config_parse_memory as a temporary solution for mono's removal of the same method. --- Make.config | 6 +-- dotnet/targets/Xamarin.Shared.Sdk.targets | 5 ++- .../Xamarin.iOS.Common.After.targets | 2 +- tests/bgen/bgen-tests.csproj | 2 +- tests/dotnet/UnitTests/DotNetUnitTests.csproj | 2 +- tests/generator/generator-tests.csproj | 2 +- tests/introspection/ApiPInvokeTest.cs | 4 ++ .../Xamarin.MacDev.Tests.csproj | 2 +- tests/mtouch/mtouch.csproj | 2 +- tools/dotnet-linker/SetupStep.cs | 39 +++++++++++-------- .../Steps/CollectAssembliesStep.cs | 16 ++++++-- tools/dotnet-linker/Steps/GenerateMainStep.cs | 16 ++++++++ 12 files changed, 67 insertions(+), 31 deletions(-) diff --git a/Make.config b/Make.config index c63fa203f361..6dd14bf9b289 100644 --- a/Make.config +++ b/Make.config @@ -483,10 +483,10 @@ DOTNET_FEED_DIR ?= $(DOTNET_DESTDIR)/nuget-feed # We're using preview versions, and there will probably be many of them, so install locally (into builds/downloads) if there's no system version to # avoid consuming a lot of disk space (since they're never automatically deleted). The system-dependencies.sh script will install locally as long # as there's a TARBALL url. -DOTNET6_VERSION=6.0.100-preview.1.21103.13 +DOTNET6_VERSION=6.0.100-preview.2.21114.3 DOTNET6_VERSION_BAND=$(firstword $(subst -, ,$(DOTNET6_VERSION))) -DOTNET6_URL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.100-preview.1.21103.13/dotnet-sdk-6.0.100-preview.1.21103.13-osx-x64.pkg -DOTNET6_TARBALL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.100-preview.1.21103.13/dotnet-sdk-6.0.100-preview.1.21103.13-osx-x64.tar.gz +DOTNET6_URL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.100-preview.2.21114.3/dotnet-sdk-6.0.100-preview.2.21114.3-osx-x64.pkg +DOTNET6_TARBALL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.100-preview.2.21114.3/dotnet-sdk-6.0.100-preview.2.21114.3-osx-x64.tar.gz DOTNET6_TARBALL_NAME=$(notdir $(DOTNET6_TARBALL)) DOTNET6_DIR=$(abspath $(TOP)/builds/downloads/$(basename $(basename $(DOTNET6_TARBALL_NAME)))) DOTNET6=$(DOTNET6_DIR)/dotnet diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index ff674b398924..8ce3e994fea4 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -125,7 +125,8 @@ false false false - false + + true false true true @@ -302,7 +303,7 @@ <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)"> - LoadReferencesStep + MarkStep Xamarin.SetupStep diff --git a/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets b/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets index a7c7d7b8afb4..676a12eb8dfa 100644 --- a/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets +++ b/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets @@ -348,7 +348,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved. <_TrimmerCustomSteps Remove="$(_AdditionalTaskAssembly)" /> <_TrimmerCustomSteps Include="$([System.String]::Copy('$(_AdditionalTaskAssembly)').Replace('$(NetCoreRoot)', '$(_RemoteDotNetDir)'))"> - LoadReferencesStep + MarkStep Xamarin.SetupStep diff --git a/tests/bgen/bgen-tests.csproj b/tests/bgen/bgen-tests.csproj index fff82edbf6e6..9eebc1d90377 100644 --- a/tests/bgen/bgen-tests.csproj +++ b/tests/bgen/bgen-tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/tests/dotnet/UnitTests/DotNetUnitTests.csproj b/tests/dotnet/UnitTests/DotNetUnitTests.csproj index ad0360653f66..bf5ff35e5a52 100644 --- a/tests/dotnet/UnitTests/DotNetUnitTests.csproj +++ b/tests/dotnet/UnitTests/DotNetUnitTests.csproj @@ -10,7 +10,7 @@ - + diff --git a/tests/generator/generator-tests.csproj b/tests/generator/generator-tests.csproj index 612d4832e820..33fba224b1f5 100644 --- a/tests/generator/generator-tests.csproj +++ b/tests/generator/generator-tests.csproj @@ -33,7 +33,7 @@ - + diff --git a/tests/introspection/ApiPInvokeTest.cs b/tests/introspection/ApiPInvokeTest.cs index 682f7a2d4d81..fa1a34824208 100644 --- a/tests/introspection/ApiPInvokeTest.cs +++ b/tests/introspection/ApiPInvokeTest.cs @@ -223,6 +223,10 @@ protected void Check (Assembly a) case "libSystem.Native": path += ".dylib"; break; + case "QCall": + if (name.StartsWith ("LogThreadPool", StringComparison.Ordinal)) + continue; + break; #endif case "libc": // we still have some rogue/not-fully-qualified DllImport diff --git a/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj b/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj index 917b0150d004..25e726d0cb23 100644 --- a/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj +++ b/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/tests/mtouch/mtouch.csproj b/tests/mtouch/mtouch.csproj index 7c301a4d144b..809c71cfee66 100644 --- a/tests/mtouch/mtouch.csproj +++ b/tests/mtouch/mtouch.csproj @@ -28,7 +28,7 @@ - + diff --git a/tools/dotnet-linker/SetupStep.cs b/tools/dotnet-linker/SetupStep.cs index 5ebb60675f17..5fc343f8f49e 100644 --- a/tools/dotnet-linker/SetupStep.cs +++ b/tools/dotnet-linker/SetupStep.cs @@ -35,6 +35,7 @@ void InsertBefore (IStep step, string stepName) return; } } + DumpSteps (); throw new InvalidOperationException ($"Could not insert {step} before {stepName} because {stepName} wasn't found."); } @@ -46,6 +47,7 @@ void InsertAfter (IStep step, string stepName) return; } } + DumpSteps (); throw new InvalidOperationException ($"Could not insert {step} after {stepName} because {stepName} wasn't found."); } @@ -57,13 +59,13 @@ protected override void TryProcess () // Load the list of assemblies loaded by the linker. // This would not be needed of LinkContext.GetAssemblies () was exposed to us. - InsertAfter (new CollectAssembliesStep (), "LoadReferencesStep"); + InsertBefore (new CollectAssembliesStep (), "MarkStep"); var pre_dynamic_dependency_lookup_substeps = new DotNetSubStepDispatcher (); - InsertBefore (pre_dynamic_dependency_lookup_substeps, "DynamicDependencyLookupStep"); + InsertBefore (pre_dynamic_dependency_lookup_substeps, "MarkStep"); var prelink_substeps = new DotNetSubStepDispatcher (); - InsertAfter (prelink_substeps, "RemoveSecurityStep"); + InsertBefore (prelink_substeps, "MarkStep"); var post_sweep_substeps = new DotNetSubStepDispatcher (); InsertAfter (post_sweep_substeps, "SweepStep"); @@ -100,24 +102,29 @@ protected override void TryProcess () Configuration.Write (); if (Configuration.Verbosity > 0) { - Console.WriteLine (); - Console.WriteLine ("Pipeline Steps:"); - foreach (var step in Steps) { - Console.WriteLine ($" {step}"); - if (step is SubStepsDispatcher) { - var substeps = typeof (SubStepsDispatcher).GetField ("substeps", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue (step) as IEnumerable; - if (substeps != null) { - foreach (var substep in substeps) { - Console.WriteLine ($" {substep}"); - } - } - } - } + DumpSteps (); } ErrorHelper.Platform = Configuration.Platform; Directory.CreateDirectory (Configuration.ItemsDirectory); Directory.CreateDirectory (Configuration.CacheDirectory); } + + void DumpSteps () + { + Console.WriteLine (); + Console.WriteLine ("Pipeline Steps:"); + foreach (var step in Steps) { + Console.WriteLine ($" {step}"); + if (step is SubStepsDispatcher) { + var substeps = typeof (SubStepsDispatcher).GetField ("substeps", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue (step) as IEnumerable; + if (substeps != null) { + foreach (var substep in substeps) { + Console.WriteLine ($" {substep}"); + } + } + } + } + } } } diff --git a/tools/dotnet-linker/Steps/CollectAssembliesStep.cs b/tools/dotnet-linker/Steps/CollectAssembliesStep.cs index 8c0cde6ce350..dc9d08dd3489 100644 --- a/tools/dotnet-linker/Steps/CollectAssembliesStep.cs +++ b/tools/dotnet-linker/Steps/CollectAssembliesStep.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Mono.Cecil; namespace Xamarin.Linker { @@ -5,12 +6,19 @@ public class CollectAssembliesStep : ConfigurationAwareStep { protected override string Name { get; } = "Collect Assemblies"; protected override int ErrorCode { get; } = 2330; - protected override void TryProcessAssembly (AssemblyDefinition assembly) + protected override void TryProcess () { - base.TryProcessAssembly (assembly); + base.TryProcess (); - Configuration.Assemblies.Add (assembly); + // This is a temporary workaround, we need to mark members and types, and we have to do it before + // the MarkStep. However, MarkStep is the first step, and if we add another step before it, + // there won't be any assemblies loaded (since MarkStep will load assemblies as needed). + // This step now runs at the very beginning, using reflection to call into the linker to load all + // the referenced assemblies, so that we can then have another step before MarkStep that does the + // custom marking we need to do. + var getReferencedAssemblies = Configuration.Context.GetType ().GetMethod ("GetReferencedAssemblies"); + var assemblies = (IEnumerable) getReferencedAssemblies.Invoke (Configuration.Context, new object [0]); + Configuration.Assemblies.AddRange (assemblies); } } } - diff --git a/tools/dotnet-linker/Steps/GenerateMainStep.cs b/tools/dotnet-linker/Steps/GenerateMainStep.cs index 8e9735b66abd..358797bae8ac 100644 --- a/tools/dotnet-linker/Steps/GenerateMainStep.cs +++ b/tools/dotnet-linker/Steps/GenerateMainStep.cs @@ -3,6 +3,7 @@ using System.Text; using Xamarin.Linker; +using Xamarin.Utils; namespace Xamarin { @@ -35,6 +36,21 @@ protected override void TryEndProcess () contents.AppendLine ("}"); contents.AppendLine (); + if (Configuration.Platform == ApplePlatform.MacOSX) { + // mono_config_parse_memory was removed in .NET: https://github.com/dotnet/runtime/pull/48007 + // however, we still use this function in our libxamarin code, and we can't remove it without affecting + // legacy Xamarin.Mac, so just add a dummy implementation of mono_config_parse_memory so that the + // native linker doesn't complain. This is a temporary solution: we'll soon build a .NET-specific + // libxamarin, in which case we can #ifdef out the call to mono_config_parse_memory for .NET only. + contents.AppendLine ("#include "); + contents.AppendLine ("extern \"C\" void mono_config_parse_memory (const char *buffer);"); + contents.AppendLine ("void mono_config_parse_memory (const char *buffer)"); + contents.AppendLine ("{"); + contents.AppendLine ("\tfprintf (stderr, \"mono_config_parse_memory has been removed\\n\");"); + contents.AppendLine ("}"); + contents.AppendLine (); + } + Configuration.Target.GenerateMain (contents, app.Platform, abi, file, registration_methods); var item = new MSBuildItem {