From bedc12dbeb6fc68b3c6091c00db4b84272202831 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 11 Oct 2024 12:59:42 +0200 Subject: [PATCH 1/2] [tools] Port mmp to .NET. * Update the makefiles to remove legacy logic. * Port the mmp project to a .NET project, and make the necessary code changes to keep it working (we still use mtouch during our build to generate the partial static registrar code). --- msbuild/Makefile | 4 - tools/common/Application.cs | 26 +- tools/common/Assembly.cs | 4 +- tools/common/DerivedLinkContext.cs | 6 +- tools/common/Driver.cs | 4 +- tools/common/StaticRegistrar.cs | 30 +- tools/common/Target.cs | 22 +- tools/linker/ApplyPreserveAttribute.cs | 10 +- tools/linker/CoreOptimizeGeneratedCode.cs | 42 +-- tools/linker/CoreTypeMapStep.cs | 10 +- tools/linker/CustomSymbolWriter.cs | 2 +- tools/linker/ExceptionalSubStep.cs | 4 +- .../MonoTouch.Tuner/ListExportedSymbols.cs | 18 +- .../PreserveSmartEnumConversions.cs | 18 +- tools/linker/ObjCExtensions.cs | 4 +- tools/mmp/Info-framework.plist.tmpl | 30 -- tools/mmp/Info.plist.tmpl | 30 -- tools/mmp/Makefile | 68 +--- tools/mmp/config | 31 -- tools/mmp/config_mobile | 17 - tools/mmp/driver.cs | 2 +- tools/mmp/machine.4_5.config | 302 ------------------ tools/mmp/mmp | 7 - tools/mmp/mmp.csproj | 62 +--- 24 files changed, 113 insertions(+), 640 deletions(-) delete mode 100644 tools/mmp/Info-framework.plist.tmpl delete mode 100644 tools/mmp/Info.plist.tmpl delete mode 100644 tools/mmp/config delete mode 100644 tools/mmp/config_mobile delete mode 100644 tools/mmp/machine.4_5.config delete mode 100755 tools/mmp/mmp diff --git a/msbuild/Makefile b/msbuild/Makefile index 9cc8d6cc1731..7e07def8f78e 100644 --- a/msbuild/Makefile +++ b/msbuild/Makefile @@ -210,7 +210,6 @@ MAC_SYMLINKS = MAC_PRODUCTS = \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild/FrameworkList.xml \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/RedistList/FrameworkList.xml \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/etc/mono/4.5/machine.config \ $(foreach target,$(MAC_TARGETS) ,$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild/$(notdir $(target))) \ $(foreach target,$(MAC_BINDING_TARGETS) ,$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild/$(notdir $(target))) \ $(foreach dll,$(MAC_TASK_ASSEMBLIES) ,$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild/$(dll).dll) \ @@ -337,9 +336,6 @@ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/RedistList/Frame $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/RedistList/FrameworkList.xml: Xamarin.Shared/Xamarin.Mac-Full-FrameworkList.xml.in Makefile | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/RedistList $(Q) sed 's@%TargetFrameworkDirectory%@$(MAC_TARGETDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5@' $< > $@ -$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/etc/mono/4.5/machine.config: $(TOP)/tools/mmp/machine.4_5.config | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/etc/mono/4.5 - $(Q) $(CP) $(TOP)/tools/mmp/machine.4_5.config $@ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild/%: Xamarin.Mac.Tasks/% | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild $(Q) install -m 644 $< $@ diff --git a/tools/common/Application.cs b/tools/common/Application.cs index b82a3e85cca8..f8f3557173f8 100644 --- a/tools/common/Application.cs +++ b/tools/common/Application.cs @@ -24,7 +24,7 @@ using PlatformResolver = MonoTouch.Tuner.MonoTouchResolver; #elif MMP using PlatformResolver = Xamarin.Bundler.MonoMacResolver; -#elif NET +#elif NET && !LEGACY_TOOLS using PlatformResolver = Xamarin.Linker.DotNetResolver; #else #error Invalid defines @@ -107,7 +107,7 @@ public bool EnableMSym { } // Linker config -#if !NET +#if !NET || LEGACY_TOOLS public LinkMode LinkMode = LinkMode.Full; #endif bool? are_any_assemblies_trimmed; @@ -115,7 +115,7 @@ public bool AreAnyAssembliesTrimmed { get { if (are_any_assemblies_trimmed.HasValue) return are_any_assemblies_trimmed.Value; -#if NET +#if NET && !LEGACY_TOOLS // This shouldn't happen, we should always set AreAnyAssembliesTrimmed to some value for .NET. throw ErrorHelper.CreateError (99, "A custom LinkMode value is not supported for .NET"); #else @@ -128,7 +128,7 @@ public bool AreAnyAssembliesTrimmed { } public List LinkSkipped = new List (); public List Definitions = new List (); -#if !NET +#if !NET || LEGACY_TOOLS public I18nAssemblies I18n; #endif public List WarnOnTypeRef = new List (); @@ -444,7 +444,7 @@ public bool ArchSpecificExecutable { } } -#if !NET +#if !NET || LEGACY_TOOLS public static int Concurrency => Driver.Concurrency; #endif public Version DeploymentTarget; @@ -552,7 +552,7 @@ public void UnsetInterpreter () InterpretedAssemblies.Clear (); } -#if !NET +#if !NET || LEGACY_TOOLS public void ParseI18nAssemblies (string i18n) { var assemblies = I18nAssemblies.None; @@ -658,7 +658,7 @@ public bool RequiresPInvokeWrappers { } } -#if NET +#if NET && !LEGACY_TOOLS public bool RequireLinkWithAttributeForObjectiveCClassSearch; #else public bool RequireLinkWithAttributeForObjectiveCClassSearch = true; @@ -836,7 +836,7 @@ public static void CopyFile (string source, string target) public void InitializeCommon () { InitializeDeploymentTarget (); -#if !NET +#if !NET || LEGACY_TOOLS SelectRegistrar (); #endif SelectMonoNative (); @@ -1263,13 +1263,13 @@ public void ParseRegistrar (string v) Registrar = RegistrarMode.PartialStatic; break; #endif -#if NET +#if NET && !LEGACY_TOOLS case "managed-static": Registrar = RegistrarMode.ManagedStatic; break; #endif default: -#if NET +#if NET && !LEGACY_TOOLS throw ErrorHelper.CreateError (20, Errors.MX0020, "--registrar", "managed-static, static, dynamic or default"); #else throw ErrorHelper.CreateError (20, Errors.MX0020, "--registrar", "static, dynamic or default"); @@ -1475,7 +1475,7 @@ public bool IsInterpreted (string assembly) if (Platform == ApplePlatform.MacOSX) throw ErrorHelper.CreateError (99, Errors.MX0099, "IsInterpreted isn't a valid operation for macOS apps."); -#if !NET +#if !NET || LEGACY_TOOLS if (IsSimulatorBuild) return false; #endif @@ -1507,7 +1507,7 @@ public bool IsInterpreted (string assembly) // revision/testing to be used so desired. public bool IsAOTCompiled (string assembly) { -#if NET +#if NET && !LEGACY_TOOLS if (Platform == ApplePlatform.MacOSX) return false; // AOT on .NET for macOS hasn't been implemented yet. #else @@ -1645,7 +1645,7 @@ public void GetAotArguments (string filename, Abi abi, string outputDir, string if (enable_llvm) aotArguments.Add ($"llvm-outfile={llvmOutputFile}"); -#if NET +#if NET && !LEGACY_TOOLS // If the interpreter is enabled, and we're building for x86_64, we're AOT-compiling but we // don't have access to infinite trampolines. So we're bumping the trampoline count (unless // the developer has already set a value) to something higher than the default. diff --git a/tools/common/Assembly.cs b/tools/common/Assembly.cs index e5197378050b..152486277c89 100644 --- a/tools/common/Assembly.cs +++ b/tools/common/Assembly.cs @@ -67,7 +67,7 @@ public string FullPath { set { full_path = value; if (!is_framework_assembly.HasValue && !string.IsNullOrEmpty (full_path)) { -#if NET +#if NET && !LEGACY_TOOLS is_framework_assembly = Target.App.Configuration.FrameworkAssemblies.Contains (GetIdentity (full_path)); #else var real_full_path = Target.GetRealPath (full_path); @@ -582,7 +582,7 @@ public void ComputeLinkerFlags () if (Frameworks.Add ("OpenAL")) Driver.Log (3, "Linking with the framework OpenAL because {0} is referenced by a module reference in {1}", file, FileName); break; -#if NET +#if NET && !LEGACY_TOOLS case "Carbon": if (App.Platform != ApplePlatform.MacOSX) { Driver.Log (3, $"Not linking with the framework {file} (referenced by a module reference in {FileName}) because it doesn't exist on the target platform."); diff --git a/tools/common/DerivedLinkContext.cs b/tools/common/DerivedLinkContext.cs index dd7e33ec4c5a..22c6dc9d2701 100644 --- a/tools/common/DerivedLinkContext.cs +++ b/tools/common/DerivedLinkContext.cs @@ -9,7 +9,7 @@ using Mono.Tuner; using Xamarin.Bundler; -#if NET +#if NET && !LEGACY_TOOLS using LinkContext = Xamarin.Bundler.DotNetLinkContext; #endif @@ -43,7 +43,7 @@ public class DerivedLinkContext : LinkContext { // so we need a second dictionary Dictionary LinkedAwayTypeMap = new Dictionary (); -#if NET +#if NET && !LEGACY_TOOLS public DerivedLinkContext (Xamarin.Linker.LinkerConfiguration configuration, Target target) : base (configuration) { @@ -103,7 +103,7 @@ public bool RequireMonoNative { get; set; } -#if !NET +#if !NET || LEGACY_TOOLS public DerivedLinkContext (Pipeline pipeline, AssemblyResolver resolver) : base (pipeline, resolver) { diff --git a/tools/common/Driver.cs b/tools/common/Driver.cs index d532e81c10a4..a1641bee39c4 100644 --- a/tools/common/Driver.cs +++ b/tools/common/Driver.cs @@ -38,7 +38,7 @@ public partial class Driver { static Version min_xcode_version = new Version (6, 0); #endif -#if !NET +#if !NET || LEGACY_TOOLS public static int Main (string [] args) { try { @@ -303,7 +303,7 @@ static bool ParseOptions (Application app, Mono.Options.OptionSet options, strin } #endif // !NET -#if !NET +#if !NET || LEGACY_TOOLS static int Jobs; public static int Concurrency { get { diff --git a/tools/common/StaticRegistrar.cs b/tools/common/StaticRegistrar.cs index 340d6a06a6dc..48a2becaade8 100644 --- a/tools/common/StaticRegistrar.cs +++ b/tools/common/StaticRegistrar.cs @@ -1598,7 +1598,7 @@ protected override IEnumerable GetProtocolMemberAttribu } } -#if !NET +#if !NET || LEGACY_TOOLS PlatformName AsPlatformName (ApplePlatform platform) { switch (platform) { @@ -1735,7 +1735,7 @@ bool GetLegacyAvailabilityAttribute (ICustomAttribute ca, ApplePlatform platform } #endif // !NET -#if NET +#if NET && !LEGACY_TOOLS bool GetDotNetAvailabilityAttribute (ICustomAttribute ca, ApplePlatform currentPlatform, out Version sdkVersion, out string message) { var caType = ca.AttributeType; @@ -1790,7 +1790,7 @@ bool CollectAvailabilityAttributes (IEnumerable attributes, ou ApplePlatform [] platforms; -#if !NET +#if !NET || LEGACY_TOOLS if (currentPlatform == ApplePlatform.MacCatalyst) { // Fall back to any iOS attributes if we can't find something for Mac Catalyst platforms = new ApplePlatform [] { @@ -1812,7 +1812,7 @@ bool CollectAvailabilityAttributes (IEnumerable attributes, ou foreach (var platform in platforms) { foreach (var ca in attributes) { var caType = ca.AttributeType; -#if NET +#if NET && !LEGACY_TOOLS if (!caType.Is ("System.Runtime.Versioning", "SupportedOSPlatformAttribute")) continue; if (GetDotNetAvailabilityAttribute (ca, platform, out sdkVersion, out message)) @@ -2265,7 +2265,7 @@ void CheckNamespace (string ns, List exceptions) } } goto default; -#if !NET +#if !NET || LEGACY_TOOLS case "Chip": switch (App.Platform) { case ApplePlatform.iOS when App.SdkVersion.Major <= 15: @@ -2348,7 +2348,7 @@ void CheckNamespace (string ns, List exceptions) } } goto default; -#if !NET +#if !NET || LEGACY_TOOLS case "QTKit": if (App.Platform == ApplePlatform.MacOSX && App.SdkVersion >= MacOSTenTwelveVersion) return; // 10.12 removed the header files for QTKit @@ -2361,7 +2361,7 @@ void CheckNamespace (string ns, List exceptions) header.WriteLine ("#import "); header.WriteLine ("#import "); return; -#if !NET +#if !NET || LEGACY_TOOLS case "iAd": if (App.SdkVersion.Major >= 13) { // most of the framework has been obliterated from the headers @@ -2810,7 +2810,7 @@ static bool IsTypeCore (ObjCType type, string nsToMatch) return ns == nsToMatch; } -#if !NET +#if !NET || LEGACY_TOOLS static bool IsQTKitType (ObjCType type) => IsTypeCore (type, "QTKit"); #endif static bool IsMapKitType (ObjCType type) => IsTypeCore (type, "MapKit"); @@ -2871,13 +2871,13 @@ List GetAllTypes (List exceptions) continue; // Some types are not supported in the simulator. } } else { -#if !NET +#if !NET || LEGACY_TOOLS if (IsQTKitType (@class) && App.SdkVersion >= MacOSTenTwelveVersion) continue; // QTKit header was removed in 10.12 SDK #endif } -#if !NET +#if !NET || LEGACY_TOOLS // Xcode 11 removed WatchKit for iOS! if (IsTypeCore (@class, "WatchKit") && App.Platform == Xamarin.Utils.ApplePlatform.iOS) { exceptions.Add (ErrorHelper.CreateWarning (4178, $"The class '{@class.Type.FullName}' will not be registered because the WatchKit framework has been removed from the iOS SDK.")); @@ -2950,7 +2950,7 @@ public CSToObjCMap GetTypeMapDictionary (List exceptions) public void Rewrite () { -#if NET +#if NET && !LEGACY_TOOLS if (App.Optimizations.RedirectClassHandles == true) { var exceptions = new List (); var map_dict = GetTypeMapDictionary (exceptions); @@ -3513,7 +3513,7 @@ bool SpecializeTrampoline (AutoIndentStringBuilder sb, ObjCMethod method, List nslog_start.AppendLine (");"); } -#if NET +#if NET && !LEGACY_TOOLS // Generate the native trampoline to call the generated UnmanagedCallersOnly method if we're using the managed static registrar. if (LinkContext.App.Registrar == RegistrarMode.ManagedStatic) { GenerateCallToUnmanagedCallersOnlyMethod (sb, method, isCtor, isVoid, num_arg, descriptiveMethodName, exceptions); @@ -4378,7 +4378,7 @@ void Specialize (AutoIndentStringBuilder sb, ObjCMethod method, List } } -#if NET +#if NET && !LEGACY_TOOLS void GenerateCallToUnmanagedCallersOnlyMethod (AutoIndentStringBuilder sb, ObjCMethod method, bool isCtor, bool isVoid, int num_arg, string descriptiveMethodName, List exceptions) { // Generate the native trampoline to call the generated UnmanagedCallersOnly method. @@ -5319,7 +5319,7 @@ bool TryCreateTokenReferenceUncached (MemberReference member, TokenType implied_ { var token = member.MetadataToken; -#if NET +#if NET && !LEGACY_TOOLS if (App.Registrar == RegistrarMode.ManagedStatic) { if (implied_type == TokenType.TypeDef && member is TypeDefinition td) { if (App.Configuration.AssemblyTrampolineInfos.TryGetValue (td.Module.Assembly, out var infos) && infos.TryGetRegisteredTypeIndex (td, out var id)) { diff --git a/tools/common/Target.cs b/tools/common/Target.cs index bafed3bb2495..0d3c4b37c43b 100644 --- a/tools/common/Target.cs +++ b/tools/common/Target.cs @@ -216,7 +216,7 @@ public void GatherFrameworks () if (Driver.GetFrameworks (App).TryGetValue (nspace, out framework)) { // framework specific processing switch (framework.Name) { -#if MONOMAC && !NET +#if MONOMAC && (!NET || LEGACY_TOOLS) case "QTKit": // we already warn in Frameworks.cs Gather method if (!Driver.LinkProhibitedFrameworks) @@ -257,7 +257,7 @@ public void GatherFrameworks () continue; } break; -#if !NET +#if !NET || !LEGACY_TOOLS case "WatchKit": // Xcode 11 doesn't ship WatchKit for iOS if (Driver.XcodeVersion.Major == 11 && App.Platform == ApplePlatform.iOS) { @@ -619,7 +619,7 @@ public void GenerateMain (StringBuilder sb, ApplePlatform platform, Abi abi, str GenerateIOSMain (sw, abi); break; case ApplePlatform.MacOSX: -#if NET +#if NET && !LEGACY_TOOLS GenerateIOSMain (sw, abi); #else GenerateMacMain (sw); @@ -641,7 +641,7 @@ void GenerateMacMain (StringWriter sw) { sw.WriteLine ("#define MONOMAC 1"); sw.WriteLine ("#include "); -#if !NET +#if !NET || LEGACY_TOOLS if (App.Registrar == RegistrarMode.PartialStatic) sw.WriteLine ($"extern \"C\" void {StaticRegistrar.GetInitializationMethodName ("Xamarin.Mac")} ();"); #endif @@ -783,7 +783,7 @@ void GenerateIOSMain (StringWriter sw, Abi abi) sw.WriteLine ("extern \"C\" { void mono_sgen_mono_ilgen_init (void); }"); } -#if NET +#if NET && !LEGACY_TOOLS if (app.MonoNativeMode != MonoNativeMode.None) { sw.WriteLine ("static const char *xamarin_runtime_libraries_array[] = {"); foreach (var lib in app.MonoLibraries) @@ -806,7 +806,7 @@ void GenerateIOSMain (StringWriter sw, Abi abi) sw.WriteLine ("\tmono_marshal_ilgen_init ();"); sw.WriteLine ("\tmono_method_builder_ilgen_init ();"); sw.WriteLine ("\tmono_sgen_mono_ilgen_init ();"); -#if !NET +#if !NET || LEGACY_TOOLS sw.WriteLine ("\tmono_ee_interp_init (NULL);"); #endif if ((abi & Abi.x86_64) == Abi.x86_64) { @@ -830,7 +830,7 @@ void GenerateIOSMain (StringWriter sw, Abi abi) sw.WriteLine ("\txamarin_invoke_registration_methods ();"); if (app.MonoNativeMode != MonoNativeMode.None) { -#if NET +#if NET && !LEGACY_TOOLS // Mono doesn't support dllmaps for Mac Catalyst / macOS in .NET, so we're using an alternative: // the PINVOKE_OVERRIDE runtime option. Since we have to use it for Mac Catalyst + macOS, let's // just use it everywhere to simplify code. This means that at runtime we need to know how we @@ -873,7 +873,7 @@ void GenerateIOSMain (StringWriter sw, Abi abi) sw.WriteLine ("\tsetenv (\"{0}\", \"{1}\", 1);", kvp.Key.Replace ("\"", "\\\""), kvp.Value.Replace ("\"", "\\\"")); if (app.XamarinRuntime != XamarinRuntime.NativeAOT) sw.WriteLine ("\txamarin_supports_dynamic_registration = {0};", app.DynamicRegistrationSupported ? "TRUE" : "FALSE"); -#if NET +#if NET && !LEGACY_TOOLS sw.WriteLine ("\txamarin_runtime_configuration_name = {0};", string.IsNullOrEmpty (app.RuntimeConfigurationFile) ? "NULL" : $"\"{app.RuntimeConfigurationFile}\""); #endif if (app.Registrar == RegistrarMode.ManagedStatic) @@ -946,7 +946,7 @@ void GenerateIOSMain (StringWriter sw, Abi abi) sw.WriteLine ("}"); } -#if NET +#if NET && !LEGACY_TOOLS static readonly char [] charsToReplaceAot = new [] { '.', '-', '+', '<', '>' }; #endif static string EncodeAotSymbol (string symbol) @@ -963,7 +963,7 @@ static string EncodeAotSymbol (string symbol) (c == '_')) { sb.Append (c); continue; -#if NET +#if NET && !LEGACY_TOOLS } else if (charsToReplaceAot.Contains (c)) { sb.Append ('_'); } else { @@ -971,7 +971,7 @@ static string EncodeAotSymbol (string symbol) sb.Append ($"_{b:X}_"); #endif } -#if !NET +#if !NET || LEGACY_TOOLS sb.Append ('_'); #endif } diff --git a/tools/linker/ApplyPreserveAttribute.cs b/tools/linker/ApplyPreserveAttribute.cs index d2ea827ff674..753fffe14385 100644 --- a/tools/linker/ApplyPreserveAttribute.cs +++ b/tools/linker/ApplyPreserveAttribute.cs @@ -13,7 +13,7 @@ namespace Xamarin.Linker.Steps { public class ApplyPreserveAttribute : ApplyPreserveAttributeBase { -#if !NET +#if !NET || LEGACY_TOOLS HashSet preserve_synonyms; #endif @@ -26,7 +26,7 @@ public override bool IsActiveFor (AssemblyDefinition assembly) return Annotations.GetAction (assembly) == AssemblyAction.Link; } -#if NET +#if NET && !LEGACY_TOOLS protected override void Process (AssemblyDefinition assembly) { base.Process (assembly); @@ -64,7 +64,7 @@ void ProcessAssemblyAttributes (AssemblyDefinition assembly) // (b) it will try to fetch the [Preserve] attribute on the type (and it's not there) as `base` would var type = tr.Resolve (); -#if NET +#if NET && !LEGACY_TOOLS PreserveType (type, attribute); #else Annotations.Mark (type); @@ -78,7 +78,7 @@ void ProcessAssemblyAttributes (AssemblyDefinition assembly) // In .NET6, ApplyPreserveAttribute no longer runs on all assemblies. // [assembly: Preserve (typeof (SomeAttribute))] no longer gives SomeAttribute "Preserve" semantics. -#if !NET +#if !NET || LEGACY_TOOLS // if the type is a custom attribute then it means we want to preserve what's decorated // with this attribute (not just the attribute alone) if (type.Inherits ("System", "Attribute")) { @@ -100,7 +100,7 @@ protected override bool IsPreservedAttribute (ICustomAttributeProvider provider, removeAttribute = true; return true; } -#if NET +#if NET && !LEGACY_TOOLS return false; #else // we need to resolve (as many reference instances can exists) diff --git a/tools/linker/CoreOptimizeGeneratedCode.cs b/tools/linker/CoreOptimizeGeneratedCode.cs index 356e3289ae67..4a653811e9cb 100644 --- a/tools/linker/CoreOptimizeGeneratedCode.cs +++ b/tools/linker/CoreOptimizeGeneratedCode.cs @@ -12,13 +12,13 @@ using Xamarin.Bundler; using MonoTouch.Tuner; -#if NET +#if NET && !LEGACY_TOOLS using Mono.Linker.Steps; #endif namespace Xamarin.Linker { -#if NET +#if NET && !LEGACY_TOOLS public class OptimizeGeneratedCodeHandler : ExceptionalMarkHandler { #else public class OptimizeGeneratedCodeSubStep : ExceptionalSubStep { @@ -30,7 +30,7 @@ public class OptimizeGeneratedCodeSubStep : ExceptionalSubStep { protected override string Name { get; } = "Binding Optimizer"; protected override int ErrorCode { get; } = 2020; -#if NET +#if NET && !LEGACY_TOOLS Dictionary _hasOptimizableCode; Dictionary HasOptimizableCode { get { @@ -76,7 +76,7 @@ protected Optimizations Optimizations { bool? is_arm64_calling_convention; -#if NET +#if NET && !LEGACY_TOOLS public override void Initialize (LinkContext context, MarkContext markContext) #else public override void Initialize (LinkContext context) @@ -112,25 +112,25 @@ public override void Initialize (LinkContext context) is_arm64_calling_convention = false; } } -#if NET +#if NET && !LEGACY_TOOLS markContext.RegisterMarkMethodAction (ProcessMethod); #endif } -#if !NET +#if !NET || LEGACY_TOOLS public override SubStepTargets Targets { get { return SubStepTargets.Assembly | SubStepTargets.Type | SubStepTargets.Method; } } #endif -#if NET +#if NET && !LEGACY_TOOLS bool IsActiveFor (AssemblyDefinition assembly, out bool hasOptimizableCode) #else public override bool IsActiveFor (AssemblyDefinition assembly) #endif { -#if NET +#if NET && !LEGACY_TOOLS hasOptimizableCode = false; if (HasOptimizableCode.TryGetValue (assembly, out bool? optimizable)) { if (optimizable == true) @@ -145,7 +145,7 @@ public override bool IsActiveFor (AssemblyDefinition assembly) #if DEBUG Console.WriteLine ("Assembly {0} : skipped (SDK)", assembly); #endif -#if NET +#if NET && !LEGACY_TOOLS HasOptimizableCode.Add (assembly, null); #endif return false; @@ -157,7 +157,7 @@ public override bool IsActiveFor (AssemblyDefinition assembly) #if DEBUG Console.WriteLine ("Assembly {0} : skipped ({1})", assembly, action); #endif -#if NET +#if NET && !LEGACY_TOOLS HasOptimizableCode.Add (assembly, null); #endif return false; @@ -183,7 +183,7 @@ public override bool IsActiveFor (AssemblyDefinition assembly) Console.WriteLine ("Assembly {0} : no [CompilerGeneratedAttribute] nor [BindingImplAttribute] present (applying basic optimizations)", assembly); #endif // we always apply the step -#if NET +#if NET && !LEGACY_TOOLS HasOptimizableCode.Add (assembly, hasOptimizableCode); #else HasOptimizableCode = hasOptimizableCode; @@ -191,7 +191,7 @@ public override bool IsActiveFor (AssemblyDefinition assembly) return true; } -#if !NET +#if !NET || LEGACY_TOOLS protected override void Process (TypeDefinition type) { if (!HasOptimizableCode) @@ -669,7 +669,7 @@ protected void EliminateDeadCode (MethodDefinition caller) bool GetInlineIntPtrSize (AssemblyDefinition assembly) { -#if NET +#if NET && !LEGACY_TOOLS if (InlineIntPtrSize.TryGetValue (assembly, out bool inlineIntPtrSize)) return inlineIntPtrSize; #else @@ -697,7 +697,7 @@ bool GetInlineIntPtrSize (AssemblyDefinition assembly) if (inlineIntPtrSize) Driver.Log (4, "Optimization 'inline-intptr-size' enabled for assembly '{0}'.", assembly.Name); -#if NET +#if NET && !LEGACY_TOOLS InlineIntPtrSize.Add (assembly, inlineIntPtrSize); #else InlineIntPtrSize = inlineIntPtrSize; @@ -705,7 +705,7 @@ bool GetInlineIntPtrSize (AssemblyDefinition assembly) return inlineIntPtrSize; } -#if !NET +#if !NET || LEGACY_TOOLS protected override void Process (AssemblyDefinition assembly) { GetInlineIntPtrSize (assembly); @@ -723,7 +723,7 @@ bool GetIsExtensionType (TypeDefinition type) protected override void Process (MethodDefinition method) { -#if NET +#if NET && !LEGACY_TOOLS if (!IsActiveFor (method.DeclaringType.Module.Assembly, out bool hasOptimizableCode)) return; #endif @@ -734,7 +734,7 @@ protected override void Process (MethodDefinition method) if (method.IsBindingImplOptimizableCode (LinkContext)) { // We optimize all methods that have the [BindingImpl (BindingImplAttributes.Optimizable)] attribute. } else if ((method.IsGeneratedCode (LinkContext) && ( -#if NET +#if NET && !LEGACY_TOOLS GetIsExtensionType (method.DeclaringType) #else IsExtensionType @@ -789,7 +789,7 @@ protected virtual int ProcessCalls (MethodDefinition caller, Instruction ins) case "get_IsDirectBinding": ProcessIsDirectBinding (caller, ins); break; -#if !NET +#if !NET || LEGACY_TOOLS // ILLink does this optimization since the property returns a constant `true` (built time) // or `false` - if `RegistrarRemovalTrackingStep` decide it's possible to do without case "get_DynamicRegistrationSupported": @@ -845,7 +845,7 @@ void ProcessEnsureUIThread (MethodDefinition caller, Instruction ins) void ProcessIntPtrSize (MethodDefinition caller, Instruction ins) { -#if NET +#if NET && !LEGACY_TOOLS if (!GetInlineIntPtrSize (caller.Module.Assembly)) return; #else @@ -877,7 +877,7 @@ void ProcessIsDirectBinding (MethodDefinition caller, Instruction ins) if (Optimizations.InlineIsDirectBinding != true) return; -#if NET +#if NET && !LEGACY_TOOLS bool? isdirectbinding_constant = IsDirectBindingConstant (caller.DeclaringType); #endif // If we don't know the constant isdirectbinding value, then we can't inline anything @@ -904,7 +904,7 @@ void ProcessIsDirectBinding (MethodDefinition caller, Instruction ins) ins.Operand = null; } -#if !NET +#if !NET || LEGACY_TOOLS void ProcessIsDynamicSupported (MethodDefinition caller, Instruction ins) { const string operation = "inline Runtime.DynamicRegistrationSupported"; diff --git a/tools/linker/CoreTypeMapStep.cs b/tools/linker/CoreTypeMapStep.cs index 2be807fe88d0..877ec85ea5b4 100644 --- a/tools/linker/CoreTypeMapStep.cs +++ b/tools/linker/CoreTypeMapStep.cs @@ -22,14 +22,14 @@ namespace MonoTouch.Tuner { // This class is shared between Xamarin.Mac and Xamarin.iOS public class CoreTypeMapStep : -#if NET +#if NET && !LEGACY_TOOLS ConfigurationAwareStep #else TypeMapStep #endif { -#if NET +#if NET && !LEGACY_TOOLS protected override string Name { get; } = "CoreTypeMap"; protected override int ErrorCode { get; } = 2390; @@ -145,7 +145,7 @@ DerivedLinkContext LinkContext { HashSet cached_isnsobject = new HashSet (); Dictionary isdirectbinding_value = new Dictionary (); -#if NET +#if NET && !LEGACY_TOOLS protected override void TryEndProcess () { #else @@ -159,12 +159,12 @@ protected override void EndProcess () } protected -#if !NET +#if !NET || LEGACY_TOOLS override #endif void MapType (TypeDefinition type) { -#if !NET +#if !NET || LEGACY_TOOLS base.MapType (type); #endif diff --git a/tools/linker/CustomSymbolWriter.cs b/tools/linker/CustomSymbolWriter.cs index 26b8928f9f30..eadad6cfaebf 100644 --- a/tools/linker/CustomSymbolWriter.cs +++ b/tools/linker/CustomSymbolWriter.cs @@ -78,7 +78,7 @@ static ImageDebugHeaderEntry ProcessEntry (ImageDebugHeaderEntry entry) public void Write (MethodDebugInformation info) => _symbolWriter.Write (info); public void Write () => _symbolWriter.Write (); public void Dispose () => _symbolWriter.Dispose (); -#if NET +#if NET && !LEGACY_TOOLS public void Write (ICustomDebugInformationProvider provider) => _symbolWriter.Write (provider); #endif } diff --git a/tools/linker/ExceptionalSubStep.cs b/tools/linker/ExceptionalSubStep.cs index 2c222ea27aa6..48b977bbedb9 100644 --- a/tools/linker/ExceptionalSubStep.cs +++ b/tools/linker/ExceptionalSubStep.cs @@ -18,7 +18,7 @@ public abstract class ExceptionalSubStep : BaseSubStep { protected DerivedLinkContext LinkContext { get { -#if NET +#if NET && !LEGACY_TOOLS return Configuration.DerivedLinkContext; #else return (DerivedLinkContext) base.context; @@ -26,7 +26,7 @@ protected DerivedLinkContext LinkContext { } } -#if NET +#if NET && !LEGACY_TOOLS protected LinkContext context { get { return Context; } } diff --git a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs index a863498b226e..8f7d5eea35c4 100644 --- a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs +++ b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs @@ -17,13 +17,13 @@ namespace Xamarin.Linker.Steps { public class ListExportedSymbols : BaseStep { PInvokeWrapperGenerator state; bool is_product_assembly; -#if !NET +#if !NET || LEGACY_TOOLS bool skip_sdk_assemblies; #endif PInvokeWrapperGenerator State { get { -#if NET +#if NET && !LEGACY_TOOLS if (state is null && DerivedLinkContext.App.RequiresPInvokeWrappers) { Configuration.PInvokeWrapperGenerationState = new PInvokeWrapperGenerator () { App = DerivedLinkContext.App, @@ -38,7 +38,7 @@ PInvokeWrapperGenerator State { } } -#if NET +#if NET && !LEGACY_TOOLS protected override void EndProcess () { if (state?.Started == true) { @@ -50,7 +50,7 @@ protected override void EndProcess () } #endif -#if NET +#if NET && !LEGACY_TOOLS public LinkerConfiguration Configuration { get { return LinkerConfiguration.GetInstance (Context); @@ -60,7 +60,7 @@ public LinkerConfiguration Configuration { public DerivedLinkContext DerivedLinkContext { get { -#if NET +#if NET && !LEGACY_TOOLS return Configuration.DerivedLinkContext; #else return (DerivedLinkContext) Context; @@ -68,7 +68,7 @@ public DerivedLinkContext DerivedLinkContext { } } -#if NET +#if NET && !LEGACY_TOOLS public ListExportedSymbols () { } @@ -87,7 +87,7 @@ protected override void ProcessAssembly (AssemblyDefinition assembly) if (Annotations.GetAction (assembly) == AssemblyAction.Delete) return; -#if !NET +#if !NET || LEGACY_TOOLS if (skip_sdk_assemblies && Profile.IsSdkAssembly (assembly)) return; #endif @@ -104,7 +104,7 @@ protected override void ProcessAssembly (AssemblyDefinition assembly) if (!hasSymbols) return; -#if NET +#if NET && !LEGACY_TOOLS is_product_assembly = Configuration.Profile.IsProductAssembly (assembly); #else is_product_assembly = Profile.IsProductAssembly (assembly); @@ -191,7 +191,7 @@ bool ProcessMethod (MethodDefinition method) } } -#if NET +#if NET && !LEGACY_TOOLS // Create a list of all the libraries from Mono that we'll link with // We add 4 different variations for each library: // * with and without a "lib" prefix diff --git a/tools/linker/MonoTouch.Tuner/PreserveSmartEnumConversions.cs b/tools/linker/MonoTouch.Tuner/PreserveSmartEnumConversions.cs index 7eacd4313c79..23e495f1f74c 100644 --- a/tools/linker/MonoTouch.Tuner/PreserveSmartEnumConversions.cs +++ b/tools/linker/MonoTouch.Tuner/PreserveSmartEnumConversions.cs @@ -16,7 +16,7 @@ using Xamarin.Bundler; namespace Xamarin.Linker.Steps { -#if NET +#if NET && !LEGACY_TOOLS public class PreserveSmartEnumConversionsHandler : ExceptionalMarkHandler #else public class PreserveSmartEnumConversionsSubStep : ExceptionalSubStep @@ -26,7 +26,7 @@ public class PreserveSmartEnumConversionsSubStep : ExceptionalSubStep protected override string Name { get; } = "Smart Enum Conversion Preserver"; protected override int ErrorCode { get; } = 2200; -#if NET +#if NET && !LEGACY_TOOLS public override void Initialize (LinkContext context, MarkContext markContext) { base.Initialize (context); @@ -40,7 +40,7 @@ public override SubStepTargets Targets { } #endif -#if NET +#if NET && !LEGACY_TOOLS bool IsActiveFor (AssemblyDefinition assembly) #else public override bool IsActiveFor (AssemblyDefinition assembly) @@ -58,7 +58,7 @@ public override bool IsActiveFor (AssemblyDefinition assembly) return false; } -#if NET +#if NET && !LEGACY_TOOLS void Mark (Tuple pair) { Context.Annotations.Mark (pair.Item1); @@ -78,7 +78,7 @@ void Preserve (Tuple pair, MethodDefinition } #endif -#if NET +#if NET && !LEGACY_TOOLS void ProcessAttributeProvider (ICustomAttributeProvider provider) #else void ProcessAttributeProvider (ICustomAttributeProvider provider, MethodDefinition conditionA, MethodDefinition conditionB = null) @@ -111,7 +111,7 @@ void ProcessAttributeProvider (ICustomAttributeProvider provider, MethodDefiniti Tuple pair; if (cache is not null && cache.TryGetValue (managedEnumType, out pair)) { -#if NET +#if NET && !LEGACY_TOOLS // The pair was already marked if it was cached. #else Preserve (pair, conditionA, conditionB); @@ -173,7 +173,7 @@ void ProcessAttributeProvider (ICustomAttributeProvider provider, MethodDefiniti if (cache is null) cache = new Dictionary> (); cache.Add (managedEnumType, pair); -#if NET +#if NET && !LEGACY_TOOLS Mark (pair); #else Preserve (pair, conditionA, conditionB); @@ -183,7 +183,7 @@ void ProcessAttributeProvider (ICustomAttributeProvider provider, MethodDefiniti protected override void Process (MethodDefinition method) { -#if NET +#if NET && !LEGACY_TOOLS static bool IsPropertyMethod (MethodDefinition method) { return method.IsGetter || method.IsSetter; @@ -213,7 +213,7 @@ static bool IsPropertyMethod (MethodDefinition method) #endif } -#if !NET +#if !NET || LEGACY_TOOLS protected override void Process (PropertyDefinition property) { ProcessAttributeProvider (property, property.GetMethod, property.SetMethod); diff --git a/tools/linker/ObjCExtensions.cs b/tools/linker/ObjCExtensions.cs index cfe09d7448a4..efcdc9ed3ff4 100644 --- a/tools/linker/ObjCExtensions.cs +++ b/tools/linker/ObjCExtensions.cs @@ -97,7 +97,7 @@ static class ObjCExtensions { public static bool IsNSObject (this TypeReference type, DerivedLinkContext link_context) { return -#if NET +#if NET && !LEGACY_TOOLS link_context.LinkerConfiguration.Context.Resolve (type) #else type.Resolve () @@ -112,7 +112,7 @@ public static bool IsNSObject (this TypeDefinition type, DerivedLinkContext link return link_context.CachedIsNSObject.Contains (type); return type.Inherits (Namespaces.Foundation, "NSObject" -#if NET +#if NET && !LEGACY_TOOLS , link_context.LinkerConfiguration.Context #endif ); diff --git a/tools/mmp/Info-framework.plist.tmpl b/tools/mmp/Info-framework.plist.tmpl deleted file mode 100644 index 061e19ffb4a2..000000000000 --- a/tools/mmp/Info-framework.plist.tmpl +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleDisplayName - @BUNDLEDISPLAYNAME@ - CFBundleExecutable - @EXECUTABLE@ - CFBundleIdentifier - @BUNDLEID@ - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - @BUNDLENAME@ - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleSupportedPlatforms - - MacOSX - - CFBundleVersion - 1 - - diff --git a/tools/mmp/Info.plist.tmpl b/tools/mmp/Info.plist.tmpl deleted file mode 100644 index 10dd9bcbbc28..000000000000 --- a/tools/mmp/Info.plist.tmpl +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleDisplayName - @BUNDLEDISPLAYNAME@ - CFBundleExecutable - @EXECUTABLE@ - CFBundleIdentifier - @BUNDLEID@ - @BUNDLEICON@CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - @BUNDLENAME@ - CFBundlePackageType - APPL - CFBundleSignature - ???? - CFBundleVersion - 0.0 - NSPrincipalClass - NSApplication - NSMainNibFile - MainWindow.nib - MonoBundleExecutable - @ASSEMBLY@ - - diff --git a/tools/mmp/Makefile b/tools/mmp/Makefile index 88ef456ee43c..be210c758496 100644 --- a/tools/mmp/Makefile +++ b/tools/mmp/Makefile @@ -9,16 +9,16 @@ export DEVELOPER_DIR=$(XCODE_DEVELOPER_ROOT) MMP_CONF=Release MMP_DIR=bin/$(MMP_CONF) -LOCAL_MMP=$(MMP_DIR)/mmp.exe -LOCAL_MMP_COMMAND=$(SYSTEM_MONO) --debug $(LOCAL_MMP) +LOCAL_MMP=$(MMP_DIR)/mmp.dll +LOCAL_MMP_COMMAND=$(DOTNET) exec $(LOCAL_MMP) # mmp.csproj.inc contains the mmp_dependencies variable used to determine if mmp needs to be rebuilt or not. mmp.csproj.inc: export BUILD_VERBOSITY=$(MSBUILD_VERBOSITY) mmp.csproj.inc: export DOTNET:=$(DOTNET) -include mmp.csproj.inc -$(MMP_DIR)/mmp.exe: $(mmp_dependencies) - $(Q_GEN) $(SYSTEM_MSBUILD) "/bl:$@.binlog" mmp.csproj /r $(XBUILD_VERBOSITY) /p:Configuration=$(MMP_CONF) +$(LOCAL_MMP): $(mmp_dependencies) + $(Q_GEN) $(DOTNET) build "/bl:$@.binlog" mmp.csproj $(XBUILD_VERBOSITY) /p:Configuration=$(MMP_CONF) MMP_TARGETS_DOTNET = \ $(DOTNET_DESTDIR)/$(osx-x64_NUGET_RUNTIME_NAME)/runtimes/osx-x64/native/Microsoft.macOS.registrar.a \ @@ -26,32 +26,10 @@ MMP_TARGETS_DOTNET = \ $(DOTNET_DESTDIR)/$(osx-x64_NUGET_RUNTIME_NAME)/runtimes/osx-x64/native/Microsoft.macOS.registrar.coreclr.a \ $(DOTNET_DESTDIR)/$(osx-arm64_NUGET_RUNTIME_NAME)/runtimes/osx-arm64/native/Microsoft.macOS.registrar.coreclr.a \ -MMP_TARGETS = \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/bin/mmp \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp/mmp.exe \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp/Xamarin.Mac.registrar.mobile.a \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp/Xamarin.Mac.registrar.full.a \ - MMP_DIRECTORIES_DOTNET = \ $(DOTNET_DESTDIR)/$(osx-x64_NUGET_RUNTIME_NAME)/runtimes/osx-x64/native \ $(DOTNET_DESTDIR)/$(osx-arm64_NUGET_RUNTIME_NAME)/runtimes/osx-arm64/native \ -MMP_DIRECTORIES = \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/bin \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp \ - $(MMP_DIRECTORIES_DOTNET) \ - -$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/bin/mmp: mmp | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/bin - $(Q) $(CP) $< $@ - -$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp/mmp.exe: $(MMP_DIR)/mmp.exe | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp - $(Q) $(CP) $(dir $<)/*.exe $(dir $@) - $(Q) $(CP) $(dir $<)/*.dll $(dir $@) - $(Q) $(CP) $(dir $<)/*.pdb $(dir $@) - -$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp/Xamarin.Mac.registrar.%.a: Xamarin.Mac.registrar.%.a | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mmp - $(Q) $(CP) $<* $(dir $@) - $(DOTNET_DESTDIR)/$(osx-x64_NUGET_RUNTIME_NAME)/runtimes/osx-x64/native/Microsoft.macOS.registrar.a: Microsoft.macOS.registrar.x86_64.a | $(DOTNET_DESTDIR)/$(osx-x64_NUGET_RUNTIME_NAME)/runtimes/osx-x64/native $(Q) $(CP) $< $@ @@ -71,15 +49,7 @@ $(MMP_DIRECTORIES): # Partial static registrar libraries # -GENERATE_PART_REGISTRAR = $(Q_GEN) $(LOCAL_MMP_COMMAND) --xamarin-framework-directory=$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR) -q --runregistrar:$(abspath $@) --sdkroot $(XCODE_DEVELOPER_ROOT) --sdk $(MACOS_SDK_VERSION) $(abspath $<) --registrar:static --nolink - -Xamarin.Mac.registrar.mobile.x86_64.m: $(TOP)/src/build/mac/mobile-64/Xamarin.Mac.dll $(LOCAL_MMP) - $(GENERATE_PART_REGISTRAR) --arch=x86_64 --target-framework Xamarin.Mac,Version=v2.0,Profile=Mobile -a:$(MOBILE_BCL_DIR)/mscorlib.dll - $(Q) touch Xamarin.Mac.registrar.mobile.x86_64.m Xamarin.Mac.registrar.mobile.x86_64.h - -Xamarin.Mac.registrar.mobile.arm64.m: $(TOP)/src/build/mac/mobile-64/Xamarin.Mac.dll $(LOCAL_MMP) - $(GENERATE_PART_REGISTRAR) --arch=arm64 --target-framework Xamarin.Mac,Version=v2.0,Profile=Mobile -a:$(MOBILE_BCL_DIR)/mscorlib.dll - $(Q) touch Xamarin.Mac.registrar.mobile.arm64.m Xamarin.Mac.registrar.mobile.arm64.h +GENERATE_PART_REGISTRAR = $(Q_GEN) $(LOCAL_MMP_COMMAND) -q --runregistrar:$(abspath $@) --sdkroot $(XCODE_DEVELOPER_ROOT) --sdk $(MACOS_SDK_VERSION) $(abspath $<) --registrar:static --nolink Microsoft.macOS.registrar.x86_64.m: $(TOP)/src/build/dotnet/macos/64/Microsoft.macOS.dll $(LOCAL_MMP) $(GENERATE_PART_REGISTRAR) --arch=x86_64 --target-framework .NETCoreApp,Version=$(subst net,,$(DOTNET_TFM)),Profile=macos -a:$(DOTNET_BCL_DIR)/System.Runtime.dll -a:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll @@ -89,10 +59,6 @@ Microsoft.macOS.registrar.coreclr.x86_64.m: $(TOP)/src/build/dotnet/macos/64/Mic $(GENERATE_PART_REGISTRAR) --arch=x86_64 --target-framework .NETCoreApp,Version=$(subst net,,$(DOTNET_TFM)),Profile=macos -a:$(DOTNET_BCL_DIR)/System.Runtime.dll -a:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll --xamarin-runtime CoreCLR $(Q) touch $@ $(basename $@).h -Xamarin.Mac.registrar.full.x86_64.m: $(TOP)/src/build/mac/full-64/Xamarin.Mac.dll $(LOCAL_MMP) - $(GENERATE_PART_REGISTRAR) --arch=x86_64 --target-framework Xamarin.Mac,Version=v4.5,Profile=Full -a:$(FULL_BCL_DIR)/mscorlib.dll - $(Q) touch Xamarin.Mac.registrar.full.x86_64.m Xamarin.Mac.registrar.full.x86_64.h - Microsoft.macOS.registrar.arm64.m: $(TOP)/src/build/dotnet/macos/64/Microsoft.macOS.dll $(LOCAL_MMP) $(GENERATE_PART_REGISTRAR) --arch=arm64 --target-framework .NETCoreApp,Version=$(subst net,,$(DOTNET_TFM)),Profile=macos -a:$(DOTNET_BCL_DIR)/System.Runtime.dll -a:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll $(Q) touch $@ $(basename $@).h @@ -101,44 +67,20 @@ Microsoft.macOS.registrar.coreclr.arm64.m: $(TOP)/src/build/dotnet/macos/64/Micr $(GENERATE_PART_REGISTRAR) --arch=arm64 --target-framework .NETCoreApp,Version=$(subst net,,$(DOTNET_TFM)),Profile=macos -a:$(DOTNET_BCL_DIR)/System.Runtime.dll -a:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll --xamarin-runtime CoreCLR $(Q) touch $@ $(basename $@).h -Xamarin.Mac.registrar.full.arm64.m: $(TOP)/src/build/mac/full-64/Xamarin.Mac.dll $(LOCAL_MMP) - $(GENERATE_PART_REGISTRAR) --arch=arm64 --target-framework Xamarin.Mac,Version=v4.5,Profile=Full -a:$(FULL_BCL_DIR)/mscorlib.dll - $(Q) touch Xamarin.Mac.registrar.full.arm64.m Xamarin.Mac.registrar.full.arm64.h - %.x86_64.a: %.x86_64.m $(Q_CC) $(MAC_CC) -DDEBUG -g -gdwarf-2 -x objective-c++ -std=c++14 -o $@ -c -arch x86_64 $< -Wall -Wno-unguarded-availability-new -I$(TOP)/runtime -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -fobjc-runtime=macosx $(EXTRA_DEFINES) %.arm64.a: %.arm64.m $(Q_CC) $(MAC_CC) -DDEBUG -g -gdwarf-2 -x objective-c++ -std=c++14 -o $@ -c -arch arm64 $< -Wall -Wno-unguarded-availability-new -I$(TOP)/runtime -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -fobjc-runtime=macosx $(EXTRA_DEFINES) -Xamarin.Mac.registrar.%.a: Xamarin.Mac.registrar.%.x86_64.a Xamarin.Mac.registrar.%.arm64.a - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ - dotnet: $(MMP_TARGETS_DOTNET) -ifdef ENABLE_DOTNET ifdef INCLUDE_MAC install-local:: $(MMP_TARGETS_DOTNET) all-local:: $(MMP_TARGETS_DOTNET) endif -endif - -ifdef INCLUDE_XAMARIN_LEGACY -ifdef INCLUDE_MAC -install-local:: $(MMP_TARGETS) -all-local:: $(MMP_TARGETS) -endif -endif clean-local:: - rm -f mmp.stub.c mmp.helper.o rm -rf bin obj - rm -f Xamarin.Mac.registrar.* - $(SYSTEM_MSBUILD) "/t:Clean" /p:Configuration=$(MMP_CONF) *.csproj include $(TOP)/mk/rules.mk include ../common/Make.common - -# make will automatically consider files created in chained implicit rules as temporary files, and delete them afterwards -# marking those files as .SECONDARY will prevent that deletion. -.SECONDARY: $(foreach ext,h m a,Xamarin.Mac.registrar.mobile.x86_64.$(ext) Xamarin.Mac.registrar.mobile.arm64.$(ext) Xamarin.Mac.registrar.full.x86_64.$(ext) Xamarin.Mac.registrar.full.arm64.$(ext)) -.SECONDARY: Xamarin.Mac.registrar.mobile.a Xamarin.Mac.registrar.full.a diff --git a/tools/mmp/config b/tools/mmp/config deleted file mode 100644 index 46c8738be6ee..000000000000 --- a/tools/mmp/config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/mmp/config_mobile b/tools/mmp/config_mobile deleted file mode 100644 index 02f8a00ae6dc..000000000000 --- a/tools/mmp/config_mobile +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/tools/mmp/driver.cs b/tools/mmp/driver.cs index 8b09f333896e..f049b5bfc23b 100644 --- a/tools/mmp/driver.cs +++ b/tools/mmp/driver.cs @@ -497,7 +497,7 @@ static void Pack (IList unprocessed) if (Profile.IsSdkAssembly (root_wo_ext) || Profile.IsProductAssembly (root_wo_ext)) throw new ProductException (3, true, Errors.MX0003, root_wo_ext); - if (App.References.Exists (a => Path.GetFileNameWithoutExtension (a).Equals (root_wo_ext))) + if (App.References.Exists (a => Path.GetFileNameWithoutExtension (a).Equals (root_wo_ext, StringComparison.Ordinal))) throw new ProductException (23, true, Errors.MM0023, root_wo_ext); fx_dir = GetPlatformFrameworkDirectory (App); diff --git a/tools/mmp/machine.4_5.config b/tools/mmp/machine.4_5.config deleted file mode 100644 index 3dd62131762a..000000000000 --- a/tools/mmp/machine.4_5.config +++ /dev/null @@ -1,302 +0,0 @@ - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- -
- - - -
- -
-
-
-
- - - - -
-
-
- -
- -
-
-
- - -
-
-
-
-
-
-
-
-
-
-
- - -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/mmp/mmp b/tools/mmp/mmp deleted file mode 100755 index 62ba80a9b783..000000000000 --- a/tools/mmp/mmp +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e - -pushd "$(dirname "$0")" > /dev/null -BIN_DIR=$(pwd -P) -popd > /dev/null - -exec /Library/Frameworks/Mono.framework/Commands/mono --debug "$BIN_DIR/../lib/mmp/mmp.exe" "$@" diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index 46ac1152a2a9..ae18dba271b6 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -1,44 +1,18 @@ - + - Debug - AnyCPU - {F3232882-0FA0-4BB6-9D9C-E2CC779EAF0D} Exe - mmp - mmp - v4.8 + net$(BundledNETCoreAppTargetFrameworkVersion) latest - - - True - portable - False - bin\Debug - MONOMAC;MMP;DEBUG - prompt - 4 - True - true - - - true - portable - False - bin\Release - prompt - MONOMAC;MMP - 4 - True + false + false + false + false + MONOMAC;MMP;LEGACY_TOOLS true - - - - - @@ -491,23 +465,7 @@ tools\common\XamarinRuntime.cs - - - config - - - config_mobile - - - machine.4_5.config - - - Info-framework.plist.tmpl - - - Info.plist.tmpl - tools\mtouch\Errors.resx ResXFileCodeGenerator @@ -568,12 +526,6 @@ Xamarin.Bundler.Errors.zh-Hant - - - - docs\website\mmp-errors.md - - From 53003b7f44e14f1e3739fc3e99cad7e3e052abf0 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 11 Oct 2024 13:18:24 +0200 Subject: [PATCH 2/2] [tools] Port mtouch to .NET. * Update the makefiles to remove legacy logic. * Port the mtouch project to a .NET project, and make the necessary code changes to keep it working (we still use mtouch during our build to generate the partial static registrar code). --- src/ObjCRuntime/PlatformAvailability2.cs | 2 +- src/ObjCRuntime/RuntimeOptions.cs | 12 +- tools/linker/RegistrarRemovalTrackingStep.cs | 8 +- tools/mtouch/Errors.designer.cs | 1 - tools/mtouch/Makefile | 384 +------------------ tools/mtouch/monotouch-fixes.c | 130 ------- tools/mtouch/mtouch | 7 - tools/mtouch/mtouch.csproj | 51 +-- tools/mtouch/simlauncher.mm | 59 --- 9 files changed, 33 insertions(+), 621 deletions(-) delete mode 100644 tools/mtouch/monotouch-fixes.c delete mode 100755 tools/mtouch/mtouch delete mode 100644 tools/mtouch/simlauncher.mm diff --git a/src/ObjCRuntime/PlatformAvailability2.cs b/src/ObjCRuntime/PlatformAvailability2.cs index 0496f9f99567..a021b458aea5 100644 --- a/src/ObjCRuntime/PlatformAvailability2.cs +++ b/src/ObjCRuntime/PlatformAvailability2.cs @@ -16,7 +16,7 @@ // // Copyright 2015 Xamarin Inc. All rights reserved. -#if !NET +#if !NET || LEGACY_TOOLS using System; using System.Text; diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index 0b2ffc2d1a36..a010735a77c7 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -19,7 +19,7 @@ namespace Xamarin.Bundler { namespace ObjCRuntime { #endif class RuntimeOptions { -#if NET +#if NET && !LEGACY_TOOLS const string SocketsHandlerValue = "SocketsHttpHandler"; #else const string HttpClientHandlerValue = "HttpClientHandler"; @@ -45,13 +45,13 @@ static string ParseHttpMessageHandler (Application app, string? value) switch (value) { // default case null: -#if NET +#if NET && !LEGACY_TOOLS return NSUrlSessionHandlerValue; #else return (app.Platform == Utils.ApplePlatform.WatchOS) ? NSUrlSessionHandlerValue : HttpClientHandlerValue; #endif case CFNetworkHandlerValue: -#if NET +#if NET && !LEGACY_TOOLS case SocketsHandlerValue: #else case HttpClientHandlerValue: @@ -100,7 +100,7 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp } else if (app.Platform == Utils.ApplePlatform.WatchOS) { handler = NSUrlSessionHandlerValue; } else { -#if NET +#if NET && !LEGACY_TOOLS handler = NSUrlSessionHandlerValue; #else handler = HttpClientHandlerValue; @@ -119,7 +119,7 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp type = platformModule!.GetType ("Foundation", "NSUrlSessionHandler"); break; #else -#if NET +#if NET && !LEGACY_TOOLS case SocketsHandlerValue: type = httpModule.GetType ("System.Net.Http", "SocketsHttpHandler"); break; @@ -180,7 +180,7 @@ internal static HttpMessageHandler GetHttpMessageHandler () var options = RuntimeOptions.Read (); // all types will be present as this is executed only when the linker is not enabled var handler_name = options?.http_message_handler; -#if NET +#if NET && !LEGACY_TOOLS // Note: no need to handle SocketsHandlerValue here because System.Net.Http handles // creating a SocketsHttpHandler when configured to do so. switch (handler_name) { diff --git a/tools/linker/RegistrarRemovalTrackingStep.cs b/tools/linker/RegistrarRemovalTrackingStep.cs index 56da6bf6260b..950f01fa69d0 100644 --- a/tools/linker/RegistrarRemovalTrackingStep.cs +++ b/tools/linker/RegistrarRemovalTrackingStep.cs @@ -6,7 +6,7 @@ using Xamarin.Bundler; using Xamarin.Linker; -#if !NET +#if !NET || LEGACY_TOOLS using Mono.Linker.Steps; using Mono.Tuner; using Xamarin.Tuner; @@ -14,7 +14,7 @@ namespace MonoTouch.Tuner { -#if NET +#if NET && !LEGACY_TOOLS public class RegistrarRemovalTrackingStep : ConfigurationAwareStep { protected override string Name { get; } = "RegistrarRemovalTracking"; @@ -146,7 +146,7 @@ bool RequiresDynamicRegistrar (AssemblyDefinition assembly, bool warnIfRequired) break; case ".ctor": var md = mr.Resolve () as MethodDefinition; -#if NET +#if NET && !LEGACY_TOOLS requires |= Xamarin.Linker.OptimizeGeneratedCodeHandler.IsBlockLiteralCtor_Type_String (md); #else requires |= Xamarin.Linker.OptimizeGeneratedCodeSubStep.IsBlockLiteralCtor_Type_String (md); @@ -179,7 +179,7 @@ void Warn (AssemblyDefinition assembly, MemberReference mr) ErrorHelper.Warning (WarnCode, Errors.MM2107, assembly.Name.Name, mr.DeclaringType.FullName, mr.Name, string.Join (", ", ((MethodReference) mr).Parameters.Select ((v) => v.ParameterType.FullName))); } -#if NET +#if NET && !LEGACY_TOOLS protected override void TryEndProcess () { #else diff --git a/tools/mtouch/Errors.designer.cs b/tools/mtouch/Errors.designer.cs index 7f9c62922ebf..bb89458e8651 100644 --- a/tools/mtouch/Errors.designer.cs +++ b/tools/mtouch/Errors.designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/tools/mtouch/Makefile b/tools/mtouch/Makefile index b8b74f4ff913..6ee9d92a7a99 100644 --- a/tools/mtouch/Makefile +++ b/tools/mtouch/Makefile @@ -5,229 +5,14 @@ include $(TOP)/Make.config # in system headers show up. export CCACHE_CPP2=1 -ifdef IOS_SUPPORTS_32BIT_ARCHITECTURES -SIMLAUNCHERS = simlauncher32-sgen simlauncher64-sgen -else -SIMLAUNCHERS = simlauncher64-sgen -endif - -UNREFERENCED_SYMBOLS = \ - _xamarin_dyn_objc_msgSend \ - _xamarin_dyn_objc_msgSendSuper \ - _xamarin_dyn_objc_msgSend_stret \ - _xamarin_dyn_objc_msgSendSuper_stret \ - _xamarin_init_nsthread \ - _xamarin_get_block_descriptor \ - _xamarin_get_locale_country_code \ - _xamarin_log \ - _xamarin_localized_string_format \ - _xamarin_localized_string_format_1 \ - _xamarin_localized_string_format_2 \ - _xamarin_localized_string_format_3 \ - _xamarin_localized_string_format_4 \ - _xamarin_localized_string_format_5 \ - _xamarin_localized_string_format_6 \ - _xamarin_localized_string_format_7 \ - _xamarin_localized_string_format_8 \ - _xamarin_localized_string_format_9 \ - _xamarin_start_wwan \ - _xamarin_timezone_get_data \ - _xamarin_timezone_get_names \ - _xamarin_timezone_get_local_name \ - _xamarin_IntPtr_objc_msgSend_IntPtr_exception \ - _xamarin_IntPtr_objc_msgSendSuper_IntPtr_exception \ - _xamarin_release_managed_ref \ - _xamarin_CGPoint__VNNormalizedFaceBoundingBoxPointForLandmarkPoint_Vector2_CGRect_nuint_nuint_string \ - _xamarin_CGPoint__VNImagePointForFaceLandmarkPoint_Vector2_CGRect_nuint_nuint_string \ - _CloseZStream \ - _CreateZStream \ - _Flush \ - _ReadZStream \ - _WriteZStream - -# The frameworks order is important as some symbols can be duplicated -# e.g. NSURLResponse is both in CFNetwork and Foundation in iOS8 but linking to -# CFNetwork will result in binaries that won't work with earlier iOS versions -SIMLAUNCHER_FRAMEWORKS = \ - -framework CoreFoundation \ - -framework CoreGraphics \ - -framework Foundation \ - -framework AVFoundation \ - -framework Accelerate \ - -framework AddressBook \ - -framework AddressBookUI \ - -framework AudioToolbox \ - -framework CFNetwork \ - -framework CoreAudio \ - -framework CoreData \ - -framework CoreLocation \ - -framework CoreText \ - -framework ExternalAccessory \ - -framework MapKit \ - -framework MediaPlayer \ - -framework MessageUI \ - -framework MobileCoreServices \ - -framework OpenAL \ - -framework OpenGLES \ - -framework StoreKit \ - -framework SystemConfiguration \ - -framework UIKit \ - \ - -weak_framework CoreMedia \ - -weak_framework CoreMidi \ - -weak_framework CoreMotion \ - -weak_framework CoreTelephony \ - -weak_framework CoreVideo \ - -weak_framework EventKit \ - -weak_framework EventKitUI \ - -weak_framework ImageIO \ - -weak_framework Security \ - -weak_framework QuickLook \ - -weak_framework iAd \ - -weak_framework Accounts \ - -weak_framework GLKit \ - -weak_framework CoreImage \ - -weak_framework CoreBluetooth \ - -weak_framework Twitter \ - -weak_framework PassKit \ - -weak_framework Social \ - -weak_framework AdSupport \ - -weak_framework JavaScriptCore \ - -weak_framework MultipeerConnectivity \ - -weak_framework SafariServices \ - -weak_framework SpriteKit \ - \ - -weak_framework HomeKit \ - -weak_framework HealthKit \ - -weak_framework LocalAuthentication \ - -weak_framework NotificationCenter \ - -weak_framework PushKit \ - -weak_framework Photos \ - -weak_framework PhotosUI \ - -weak_framework SceneKit \ - -weak_framework CloudKit \ - -weak_framework AVKit \ - -weak_framework WebKit \ - -weak_framework NetworkExtension \ - -weak_framework Metal \ - -weak_framework CoreAudioKit \ - \ - -weak_framework ReplayKit \ - -weak_framework Contacts \ - -weak_framework ContactsUI \ - -weak_framework CoreSpotlight \ - -weak_framework WatchConnectivity \ - -weak_framework ModelIO \ - -weak_framework GameplayKit \ - -weak_framework Metal \ - -weak_framework MetalKit \ - -weak_framework MetalPerformanceShaders \ - -weak_framework MetalPerformanceShadersGraph\ - \ - -weak_framework HealthKitUI \ - \ - -weak_framework CallKit \ - -weak_framework Messages \ - -weak_framework Speech \ - -weak_framework VideoSubscriberAccount \ - -weak_framework UserNotifications \ - -weak_framework UserNotificationsUI \ - -weak_framework Intents \ - -weak_framework IntentsUI \ - \ - -weak_framework ARKit \ - -weak_framework FileProvider \ - -weak_framework FileProviderUI \ - \ - -weak_framework IdentityLookup \ - -weak_framework BusinessChat \ - -weak_framework ClassKit \ - \ - -weak_framework AuthenticationServices \ - -weak_framework CarPlay \ - -weak_framework IdentityLookupUI \ - -weak_framework NaturalLanguage \ - -weak_framework Network \ - -weak_framework IdentityLookupUI \ - -weak_framework VisionKit \ - \ - -weak_framework BackgroundTasks \ - -weak_framework CoreHaptics \ - -weak_framework LinkPresentation \ - -weak_framework MetricKit \ - -weak_framework PencilKit \ - -weak_framework QuickLookThumbnailing \ - -weak_framework SoundAnalysis \ - -weak_framework VisionKit \ - \ - -weak_framework AutomaticAssessmentConfiguration \ - \ - -weak_framework Accessibility \ - -weak_framework AppClip \ - -weak_framework AppTrackingTransparency \ - -weak_framework ScreenTime \ - -weak_framework SensorKit \ - -weak_framework UniformTypeIdentifiers \ - -weak_framework NearbyInteraction \ - \ - -weak_framework AdServices \ - \ - -weak_framework CoreLocationUI \ - -weak_framework OSLog \ - \ - -weak_framework AVRouting \ - -weak_framework BackgroundAssets \ - -weak_framework SafetyKit \ - -weak_framework DeviceDiscoveryExtension \ - -weak_framework SharedWithYou \ - -weak_framework SharedWithYouCore \ - \ - -weak_framework Symbols \ - -weak_framework SensitiveContentAnalysis \ - -weak_framework BrowserEngineKit \ - -SIMLAUNCHER64_FRAMEWORKS = \ - -framework GameKit \ -# keep the above list of weak_framework -# 1. grouped by iOS versions; -# 2. sorted and -# 3. in sync with the list inside `tools/common/Frameworks.cs` -# except it is no a mistake that GameController and MediaAccessibility (#13636) are not built into simlauncher - -# note: there _was_ no CoreAudioKit.framework or Metal.framework for the simulator (before recent iOS9 betas) -# note 2: there's no GameKit, in iOS 9 (beta 3 at least), you're supposed to reference GameCenter instead (looks fixed in beta 4) -# note 3: there's no MetalKit or MetalPerformanceShaders in iOS 9 beta 4 - but other frameworks were added -# note 4: GameCenter was removed in Xcode 7 beta 5, and GameKit is back. -# note 5: Metal* seems to be supported as of some Xcode 7 beta (b2 didn't, but the final release does) -# note 6: Xcode 11 beta 1 shipped without WatchKit. -# note 7: Xcode 11 beta 3 documented that shipping without WatchKit was done on purpose (in the release notes). -# note 8: Xcode 14 beta 2 removed GameKit for 32-bit iOS - -define SimlauncherTemplate - -simlauncher$(3)-sgen: simlauncher.mm $(TOP)/runtime/.libs/iphonesimulator/libxamarin-debug.a Makefile Xamarin.iOS.registrar.ios.simulator.a - $(QT_CC) $(SIMULATOR_CC) -DDEBUG -DSIMLAUNCHER $(1) -gdwarf-2 \ - -L$(TOP)/runtime/.libs/iphonesimulator \ - -I$(TOP)/runtime \ - $(MONO_IOS_SDK_DESTDIR)/ios-libs/ios-sim/libmonosgen-2.0.a \ - $(foreach u,$(UNREFERENCED_SYMBOLS),-u $u) \ - $(TOP)/runtime/.libs/iphonesimulator/libapp.a \ - -Wl,-w \ - -lz -liconv $(TOP)/runtime/.libs/iphonesimulator/libxamarin-debug.a simlauncher.mm $(SIMLAUNCHER_FRAMEWORKS) $(SIMLAUNCHER$(3)_FRAMEWORKS) $(SIMULATOR$(2)_OBJC_CFLAGS) -o $$@ - $(Q) xcrun otool -L $$@ > $$@.frameworks -endef - -$(eval $(call SimlauncherTemplate,Xamarin.iOS.registrar.ios.simulator.a,86,32)) -$(eval $(call SimlauncherTemplate,Xamarin.iOS.registrar.ios.simulator.a,64,64)) - # # mtouch # MTOUCH_CONF=Release MTOUCH_DIR=bin/$(MTOUCH_CONF) -LOCAL_MTOUCH=$(MTOUCH_DIR)/mtouch.exe -LOCAL_MTOUCH_COMMAND=$(SYSTEM_MONO) --debug $(LOCAL_MTOUCH) +LOCAL_MTOUCH=$(MTOUCH_DIR)/mtouch.dll +LOCAL_MTOUCH_COMMAND=$(DOTNET) exec $(LOCAL_MTOUCH) DOTNET_PLATFORMS_MTOUCH=$(filter-out macOS,$(DOTNET_PLATFORMS)) @@ -236,8 +21,8 @@ mtouch.csproj.inc: export BUILD_VERBOSITY=$(MSBUILD_VERBOSITY) mtouch.csproj.inc: export DOTNET:=$(DOTNET) -include mtouch.csproj.inc -$(MTOUCH_DIR)/mtouch.exe: $(mtouch_dependencies) - $(Q_GEN) $(SYSTEM_MSBUILD) mtouch.csproj /r $(XBUILD_VERBOSITY) /p:Configuration=$(MTOUCH_CONF) +$(LOCAL_MTOUCH): $(mtouch_dependencies) + $(Q_GEN) $(DOTNET) build mtouch.csproj $(DOTNET_BUILD_VERBOSITY) /p:Configuration=$(MTOUCH_CONF) $(abspath Constants.cs): Constants.cs.in Makefile $(TOP)/Make.config.inc $(Q_GEN) sed \ @@ -248,158 +33,36 @@ $(abspath Constants.cs): Constants.cs.in Makefile $(TOP)/Make.config.inc # Partial static registrar libraries # define RunRegistrar -%.registrar.$(1).$(2).m %.registrar.$(1).$(2).h: $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/$(3)bits/$(9)/%.dll $(LOCAL_MTOUCH) - $$(Q_GEN) $$(LOCAL_MTOUCH_COMMAND) --xamarin-framework-directory=$$(IOS_DESTDIR)/$$(MONOTOUCH_PREFIX) $$(MTOUCH_VERBOSITY) --runregistrar:$$(abspath $$(basename $$@).m) --sdkroot $$(XCODE_DEVELOPER_ROOT) --sdk $(4) $$< --registrar:static --target-framework Xamarin.$(5),v1.0 --abi $(2) -r:$(8)/mscorlib.dll - $$(Q) touch $$(basename $$@).m $$(basename $$@).h - .libs/Microsoft.$(9).registrar.$(10)%m .libs/Microsoft.$(9).registrar.$(10)%h: $(TOP)/src/build/dotnet/$(1)/$(3)/Microsoft.$(9).dll $(LOCAL_MTOUCH) | .libs - $$(Q_GEN) $$(LOCAL_MTOUCH_COMMAND) --xamarin-framework-directory=$$(IOS_DESTDIR)/$$(MONOTOUCH_PREFIX) $$(MTOUCH_VERBOSITY) --runregistrar:$$(abspath $$(basename $$@).m) --sdkroot $$(XCODE_DEVELOPER_ROOT) --sdk $(4) $$< --registrar:static --target-framework .NETCoreApp,Version=$(subst net,,$(DOTNET_TFM)),Profile=$(1) --abi $(2) -r:$(DOTNET_BCL_DIR)/System.Runtime.dll -r:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll --rid $(10) + $$(Q_GEN) $$(LOCAL_MTOUCH_COMMAND) $$(MTOUCH_VERBOSITY) --runregistrar:$$(abspath $$(basename $$@).m) --sdkroot $$(XCODE_DEVELOPER_ROOT) --sdk $(4) $$< --registrar:static --target-framework .NETCoreApp,Version=$(subst net,,$(DOTNET_TFM)),Profile=$(1) --abi $(2) -r:$(DOTNET_BCL_DIR)/System.Runtime.dll -r:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll --rid $(10) $$(Q) touch $$(basename $$@).m $$(basename $$@).h -%.registrar.$(1).$(2).a: %.registrar.$(1).$(2).m %.registrar.$(1).$(2).h - $$(Q_CC) $$(IOS_CC) -DDEBUG -g -gdwarf-2 $(6) -stdlib=libc++ -std=c++14 -x objective-c++ -o $$@ -c $$< -Wall -Wno-unguarded-availability-new -I$(7) -I$(TOP)/runtime - .libs/Microsoft.$(9).registrar.$(10).a: .libs/Microsoft.$(9).registrar.$(10).m .libs/Microsoft.$(9).registrar.$(10).h | .libs - $$(Q_CC) $$(IOS_CC) -DDEBUG -g -gdwarf-2 $(6) -stdlib=libc++ -std=c++14 -x objective-c++ -o $$@ -c $$< -Wall -Wno-unguarded-availability-new -I$(7) -I$(TOP)/runtime - -# make will automatically consider files created in chained implicit rules as temporary files, and delete them afterwards -# marking those files as .SECONDARY will prevent that deletion. -.SECONDARY: Xamarin.$(5).registrar.$(1).$(2).m Xamarin.$(5).registrar.$(1).$(2).h Xamarin.$(5).registrar.$(1).$(2).a -.SECONDARY: .libs/Microsoft.$(8).registrar.$(2).m .libs/Microsoft.$(8).registrar.$(2).h .libs/Microsoft.$(8).registrar.$(2).a + $$(Q_CC) $$(IOS_CC) -DDEBUG -g -gdwarf-2 $(6) -stdlib=libc++ -std=c++14 -x objective-c++ -o $$@ -c $$< -Wall -Wno-unguarded-availability-new -I$(TOP)/runtime endef -ifdef IOS_SUPPORTS_32BIT_ARCHITECTURES -$(eval $(call RunRegistrar,ios,i386,32,$(IOS_SDK_VERSION),iOS,$(SIMULATOR86_CFLAGS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphonesimulator.sdk/include,$(MONOTOUCH_MONO_PATH),iOS,iossimulator-x86)) -endif -$(eval $(call RunRegistrar,ios,x86_64,64,$(IOS_SDK_VERSION),iOS,$(SIMULATOR64_CFLAGS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphonesimulator.sdk/include,$(MONOTOUCH_MONO_PATH),iOS,iossimulator-x64)) -$(eval $(call RunRegistrar,ios,arm64,64,$(IOS_SDK_VERSION),iOS,$(SIMULATOR_ARM64_CFLAGS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphonesimulator.sdk/include,$(MONOTOUCH_MONO_PATH),iOS,iossimulator-arm64)) -ifdef IOS_SUPPORTS_32BIT_ARCHITECTURES -$(eval $(call RunRegistrar,ios,armv7,32,$(IOS_SDK_VERSION),iOS,$(DEVICE7_CFLAGS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphoneos.sdk/include,$(MONOTOUCH_MONO_PATH),iOS,armv7)) -$(eval $(call RunRegistrar,ios,armv7s,32,$(IOS_SDK_VERSION),iOS,$(DEVICE7S_CFLAGS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphoneos.sdk/include,$(MONOTOUCH_MONO_PATH),iOS,armv7s)) -endif -$(eval $(call RunRegistrar,ios,arm64,64,$(IOS_SDK_VERSION),iOS,$(DEVICE64_CFLAGS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphoneos.sdk/include,$(MONOTOUCH_MONO_PATH),iOS,ios-arm64)) -$(eval $(call RunRegistrar,tvos,x86_64,64,$(TVOS_SDK_VERSION),TVOS,$(SIMULATORTV_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/include,$(MONOTOUCH_TV_MONO_PATH),tvOS,tvossimulator-x64)) -$(eval $(call RunRegistrar,tvos,arm64,64,$(TVOS_SDK_VERSION),TVOS,$(SIMULATORTV_ARM64_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/include,$(MONOTOUCH_TV_MONO_PATH),tvOS,tvossimulator-arm64)) -$(eval $(call RunRegistrar,tvos,arm64,64,$(TVOS_SDK_VERSION),TVOS,$(DEVICETV_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/include,$(MONOTOUCH_TV_MONO_PATH),tvOS,tvos-arm64)) -$(eval $(call RunRegistrar,watchos,x86_64,64,$(WATCH_SDK_VERSION),WatchOS,$(SIMULATORWATCH64_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_WATCHSIMULATOR_SDK)/include,$(MONOTOUCH_WATCH_MONO_PATH),watchOS,watchos-x64)) -ifdef WATCHOS_SUPPORTS_32BIT_SIMULATOR_ARCHITECTURES -$(eval $(call RunRegistrar,watchos,i386,32,$(WATCH_SDK_VERSION),WatchOS,$(SIMULATORWATCH_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_WATCHSIMULATOR_SDK)/include,$(MONOTOUCH_WATCH_MONO_PATH),watchOS,watchos-x86)) -endif -ifdef WATCHOS_SUPPORTS_32BIT_DEVICE_ARCHITECTURES -$(eval $(call RunRegistrar,watchos,armv7k,32,$(WATCH_SDK_VERSION),WatchOS,$(DEVICEWATCH_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_WATCHOS_SDK)/include,$(MONOTOUCH_WATCH_MONO_PATH),watchOS,armv7k)) -endif -$(eval $(call RunRegistrar,watchos,arm64_32,32,$(WATCH_SDK_VERSION),WatchOS,$(DEVICEWATCH64_32_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_WATCHOS_SDK)/include,$(MONOTOUCH_WATCH_MONO_PATH),watchOS,arm64_32)) -$(eval $(call RunRegistrar,maccatalyst,x86_64,64,$(MACCATALYST_SDK_VERSION),MacCatalyst,$(MACCATALYST_X86_64_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_MACCATALYST_SDK)/include,$(MONOTOUCH_MACCATALYST_MONO_PATH),MacCatalyst,maccatalyst-x64)) -$(eval $(call RunRegistrar,maccatalyst,arm64,64,$(MACCATALYST_SDK_VERSION),MacCatalyst,$(MACCATALYST_ARM64_CFLAGS),$(IOS_DESTDIR)$(XAMARIN_MACCATALYST_SDK)/include,$(MONOTOUCH_MACCATALYST_MONO_PATH),MacCatalyst,maccatalyst-arm64)) - -ifdef IOS_SUPPORTS_32BIT_ARCHITECTURES -%.registrar.ios.simulator.a: %.registrar.ios.i386.a %.registrar.ios.x86_64.a -else -%.registrar.ios.simulator.a: %.registrar.ios.x86_64.a -endif - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ - -ifdef IOS_SUPPORTS_32BIT_ARCHITECTURES -%.registrar.ios.device.a: %.registrar.ios.arm64.a %.registrar.ios.armv7.a %.registrar.ios.armv7s.a -else -%.registrar.ios.device.a: %.registrar.ios.arm64.a -endif - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ - -ifdef WATCHOS_SUPPORTS_32BIT_DEVICE_ARCHITECTURES -%.registrar.watchos.device.a: %.registrar.watchos.armv7k.a %.registrar.watchos.arm64_32.a -else -%.registrar.watchos.device.a: %.registrar.watchos.arm64_32.a -endif - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ - -ifdef WATCHOS_SUPPORTS_32BIT_SIMULATOR_ARCHITECTURES -%.registrar.watchos.simulator.a: %.registrar.watchos.i386.a %.registrar.watchos.x86_64.a -else -%.registrar.watchos.simulator.a: %.registrar.watchos.x86_64.a -endif - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ - -.libs/Microsoft.iOS.registrar.ios-arm.a: .libs/Microsoft.iOS.registrar.armv7.a .libs/Microsoft.iOS.registrar.armv7s.a - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ - -.libs/Microsoft.watchOS.registrar.watchos-arm.a: .libs/Microsoft.watchOS.registrar.armv7k.a .libs/Microsoft.watchOS.registrar.arm64_32.a - $(Q_LIPO) $(DEVICE_BIN_PATH)/lipo -create -output $@ $^ +$(eval $(call RunRegistrar,ios,x86_64,64,$(IOS_SDK_VERSION),iOS,$(SIMULATOR64_CFLAGS),,,iOS,iossimulator-x64)) +$(eval $(call RunRegistrar,ios,arm64,64,$(IOS_SDK_VERSION),iOS,$(SIMULATOR_ARM64_CFLAGS),,,iOS,iossimulator-arm64)) +$(eval $(call RunRegistrar,ios,arm64,64,$(IOS_SDK_VERSION),iOS,$(DEVICE64_CFLAGS),,,iOS,ios-arm64)) +$(eval $(call RunRegistrar,tvos,x86_64,64,$(TVOS_SDK_VERSION),TVOS,$(SIMULATORTV_CFLAGS),,,tvOS,tvossimulator-x64)) +$(eval $(call RunRegistrar,tvos,arm64,64,$(TVOS_SDK_VERSION),TVOS,$(SIMULATORTV_ARM64_CFLAGS),,,tvOS,tvossimulator-arm64)) +$(eval $(call RunRegistrar,tvos,arm64,64,$(TVOS_SDK_VERSION),TVOS,$(DEVICETV_CFLAGS),,,tvOS,tvos-arm64)) +$(eval $(call RunRegistrar,maccatalyst,x86_64,64,$(MACCATALYST_SDK_VERSION),MacCatalyst,$(MACCATALYST_X86_64_CFLAGS),,,MacCatalyst,maccatalyst-x64)) +$(eval $(call RunRegistrar,maccatalyst,arm64,64,$(MACCATALYST_SDK_VERSION),MacCatalyst,$(MACCATALYST_ARM64_CFLAGS),,,MacCatalyst,maccatalyst-arm64)) TARGETS_DOTNET = \ $(foreach platform,$(DOTNET_PLATFORMS_MTOUCH),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(DOTNET_DESTDIR)/$($(rid)_NUGET_RUNTIME_NAME)/runtimes/$(rid)/native/Microsoft.$(platform).registrar.a)) \ -TARGETS = \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/mtouch \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mtouch/mtouch.exe \ - $(foreach launcher,$(SIMLAUNCHERS),$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/$(launcher)) \ - $(IOS_DESTDIR)$(MONOTOUCH_SIMULATOR_SDK)/lib/Xamarin.iOS.registrar.a \ - -ifdef INCLUDE_DEVICE -TARGETS += $(IOS_DESTDIR)$(MONOTOUCH_DEVICE_SDK)/lib/Xamarin.iOS.registrar.a -endif - -ifdef INCLUDE_TVOS -TARGETS += \ - $(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib/Xamarin.TVOS.registrar.a \ - -ifdef INCLUDE_DEVICE -TARGETS += $(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/lib/Xamarin.TVOS.registrar.a -endif -endif - TARGET_DIRS_DOTNET = \ $(foreach platform,$(DOTNET_PLATFORMS_MTOUCH),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(DOTNET_DESTDIR)/$($(rid)_NUGET_RUNTIME_NAME)/runtimes/$(rid)/native)) \ TARGET_DIRS = \ .libs \ bin/Makefile \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mtouch \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/etc/mono/assemblies/System \ - $(IOS_DESTDIR)$(MONOTOUCH_SIMULATOR_SDK)/lib \ - $(IOS_DESTDIR)$(MONOTOUCH_DEVICE_SDK)/lib \ - $(IOS_DESTDIR)$(XAMARIN_WATCHSIMULATOR_SDK)/lib \ - $(IOS_DESTDIR)$(XAMARIN_WATCHOS_SDK)/lib \ - $(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib \ - $(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/lib \ $(TARGET_DIRS_DOTNET) \ $(TARGET_DIRS): $(Q) mkdir -p $@ -$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mtouch/mtouch.exe: $(MTOUCH_DIR)/mtouch.exe | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mtouch - $(Q) $(CP) $(dir $<)/*.exe $(dir $@) - $(Q) $(CP) $(dir $<)/*.dll $(dir $@) - $(Q) $(CP) $(dir $<)/*.pdb $(dir $@) - -$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/mtouch: mtouch | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/%: % | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/%: % | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(MONOTOUCH_SIMULATOR_SDK)/lib/%.registrar.a: %.registrar.ios.simulator.a | $(IOS_DESTDIR)$(MONOTOUCH_SIMULATOR_SDK)/lib - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(XAMARIN_WATCHSIMULATOR_SDK)/lib/%.registrar.a: %.registrar.watchos.simulator.a | $(IOS_DESTDIR)$(XAMARIN_WATCHSIMULATOR_SDK)/lib - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib/%.registrar.a: %.registrar.tvos.x86_64.a | $(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(MONOTOUCH_DEVICE_SDK)/lib/%.registrar.a: %.registrar.ios.device.a | $(IOS_DESTDIR)$(MONOTOUCH_DEVICE_SDK)/lib - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(XAMARIN_WATCHOS_SDK)/lib/%.registrar.a: %.registrar.watchos.device.a | $(IOS_DESTDIR)$(XAMARIN_WATCHOS_SDK)/lib - $(Q) $(CP) $< $@ - -$(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/lib/%.registrar.a: %.registrar.tvos.arm64.a | $(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/lib - $(Q) $(CP) $< $@ - define InstallRegistrar $(DOTNET_DESTDIR)/$$($(2)_NUGET_RUNTIME_NAME)/runtimes/$(2)/native/Microsoft.$(1).registrar.a: .libs/Microsoft.$(1).registrar.$(rid).a | $(DOTNET_DESTDIR)/$($(2)_NUGET_RUNTIME_NAME)/runtimes/$(2)/native $(Q) $(CP) $$< $$@ @@ -408,26 +71,11 @@ endef $(foreach platform,$(DOTNET_PLATFORMS_MTOUCH),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(eval $(call InstallRegistrar,$(platform),$(rid))))) dotnet: $(TARGETS_DOTNET) -ifdef ENABLE_DOTNET install-local:: $(TARGETS_DOTNET) all-local:: $(TARGETS_DOTNET) -endif - -ifdef INCLUDE_XAMARIN_LEGACY -ifdef INCLUDE_IOS -install-local:: $(TARGETS) -all-local:: $(TARGETS) -endif -endif - -install-mtouch: \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/mtouch \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mtouch/mtouch.exe \ clean-local:: rm -Rf bin obj - rm -f $(SIMLAUNCHERS) - $(SYSTEM_MSBUILD) "/t:Clean" /p:Configuration=$(MTOUCH_CONF) *.csproj all-local:: verify-sorted-resx verify-sorted-resx: @@ -447,7 +95,3 @@ clean-dotnet: include $(TOP)/mk/rules.mk include ../common/Make.common - -# make will automatically consider files created in chained implicit rules as temporary files, and delete them afterwards -# marking those files as .SECONDARY will prevent that deletion. -.SECONDARY: Xamarin.iOS.registrar.ios.simulator.a Xamarin.iOS.registrar.ios.device.a Xamarin.WatchOS.registrar.watchos.device.a diff --git a/tools/mtouch/monotouch-fixes.c b/tools/mtouch/monotouch-fixes.c deleted file mode 100644 index 1186e7860860..000000000000 --- a/tools/mtouch/monotouch-fixes.c +++ /dev/null @@ -1,130 +0,0 @@ -// -// monotouch-fixes.c: -// -// Author: -// Rolf Bjarne Kvinge -// -// Copyright 2011 Xamarin Inc. -// - -#include -#include -#include -#include -#include -#include -#include -#include - -// Apple uses LLVM to implement OpenGL ES on the iPhone Simulator, unfortunately -// LLVM has a race condition in their signal handling - they set one-shot -// signal handlers and restore the previous handler in those handlers. The -// problem is that they set SA_RESETHAND|SA_NODEFER when setting their signal -// handler, which means that if another signal arrives before their signal handler -// has been able to restore our signal handler, the default signal handler will -// be called (which just exits the process without any diagnostics at all). -// -// For the 32bit simulator we inject our own sigaction method, which takes precedence -// over the system one, and reset the flags to 0 if flags is SA_RESETHAND|SA_NODEFER. -// -// Unfortunately this technique does not seem to work for the 64bit simulator, so there -// we patch the system sigaction instead. -// - -typedef int (*SigAction) (int sig, const struct sigaction *__restrict act, struct sigaction *__restrict oact); -static SigAction system_sigaction = sigaction; - -static int -my_sigaction (int sig, const struct sigaction *__restrict act, struct sigaction *__restrict oact) -{ - //fprintf (stderr, "my_sigaction (%i, %p: handler = %p mask = %i flags = %i, %p)\n", sig, act, act ? act->sa_handler : NULL, act ? act->sa_mask : -1, act ? act->sa_flags : -1, oact); - - if (act && act->sa_flags == (SA_NODEFER | SA_RESETHAND)) { - switch (sig) { - case SIGUSR1: - case SIGUSR2: - case SIGFPE: - // fprintf (stderr, "fixed up sicaction (%i, %p: handler = %p mask = %i flags = %i, %p)\n", sig, act, act ? act->sa_handler : NULL, act ? act->sa_mask : -1, act ? act->sa_flags : -1, oact); - ((struct sigaction *) act)->sa_flags = 0; - break; - } - } - - return system_sigaction (sig, act, oact); -} - -#if defined(__i386__) - -typedef struct interpose_s { - void *new_func; - void *orig_func; -} interpose_t; - -static const interpose_t interposers[] __attribute__ ((unused)) \ - __attribute__ ((section("__DATA, __interpose"))) = { - { (void *) &my_sigaction, (void *) &sigaction }, - }; - -#elif defined(__x86_64__) - -static void -patch_sigaction () -{ - // Sanity check. - uint64_t * func = (uint64_t *) &sigaction; - uint64_t first = 0x20ec8348e5894855; // first 8 bytes of sigaction - uint64_t second = 0x0a771ef883ff478d; // second 8 bytes of sigaction - if (func [0] != first || func [1] != second) { - fprintf (stderr, "MonoTouch: Could not install sigaction override, unexpected sigaction implementation.\n"); - return; - } - - // allocate executable memory - uint64_t pagesize = (uint64_t) getpagesize (); - void *exec = mmap (NULL, pagesize, PROT_EXEC | PROT_WRITE | PROT_READ, MAP_ANON | MAP_PRIVATE, -1, 0); - if (exec == NULL) { - fprintf (stderr, "MonoTouch: Could not allocate memory for sigaction override: %s\n", strerror (errno)); - return; - } - - // create a trampoline that jumps to the real sigaction (to just after where we modified it). - uint64_t *i64 = (uint64_t *) exec; - i64 [0] = first; - i64 [1] = second; - uint16_t *i16 = (uint16_t *) exec; - // movabsq &sigaction + 14,%r11 - i16 [7] = 0xbb49; - i64 [2] = (uint64_t) (14 + (char *) &sigaction); - // jmpq *%r11 - i16 [12] = 0xff41; - i16 [13] = 0x00e3; - - // make sigaction patchable. - uint64_t symbol = (uint64_t) (char *) &sigaction; - void *aligned_symbol = (void *) (symbol & ~(pagesize - 1)); - int ret; - - ret = mprotect (aligned_symbol, pagesize * 2, PROT_READ | PROT_WRITE | PROT_EXEC); - - if (ret != 0) { - fprintf (stderr, "MonoTouch: could not patch sigaction: %s\n", strerror (errno)); - munmap (exec, pagesize); - return; - } - - // patch sigaction to call my_sigaction instead. - uint16_t *f16 = (uint16_t *) &sigaction; - // movabsq my_sigaction,%r11 - f16 [0] = 0xbb49; - uint64_t *f64 = (uint64_t *) (f16 + 1); - f64 [0] = (uint64_t) &my_sigaction; - // jmpq *%r11 - f16 [5] = 0xff41; - f16 [6] = 0x00e3; - - // Make sigaction non-writeable again. - mprotect (aligned_symbol, pagesize * 2, PROT_READ | PROT_EXEC); - - system_sigaction = (SigAction) exec; -} -#endif diff --git a/tools/mtouch/mtouch b/tools/mtouch/mtouch deleted file mode 100755 index 5b4baf57301b..000000000000 --- a/tools/mtouch/mtouch +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e - -pushd "$(dirname "$0")/.." > /dev/null -MONOTOUCH_PREFIX=$(pwd -P) -popd > /dev/null - -exec /Library/Frameworks/Mono.framework/Commands/mono64 --debug "$MONOTOUCH_PREFIX/lib/mtouch/mtouch.exe" "$@" diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 471433bd1381..66c01efa7f88 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -1,38 +1,16 @@ - + - Debug - AnyCPU - {A737EFCC-4348-4EB1-9C14-4FDC0975388D} Exe - mtouch - mtouch - v4.8 + net$(BundledNETCoreAppTargetFrameworkVersion) latest - - - True - portable - False - bin\Debug - MONOTOUCH;MTOUCH;DEBUG - prompt - 4 - True + false + false + false + false + false + MONOTOUCH;MTOUCH;LEGACY_TOOLS true - latest - - - true - portable - False - bin\Release - prompt - MONOTOUCH;MTOUCH - 4 - True - true - latest @@ -505,23 +483,10 @@ tools\linker\RegistrarRemovalTrackingStep.cs - - - - - - - - - - - docs\website\mtouch-errors.md - - Resx diff --git a/tools/mtouch/simlauncher.mm b/tools/mtouch/simlauncher.mm deleted file mode 100644 index 2c43d9a6a0b0..000000000000 --- a/tools/mtouch/simlauncher.mm +++ /dev/null @@ -1,59 +0,0 @@ -// -// simlauncher.m: Defaults for the simlauncher binaries -// -// Authors: -// Rolf Bjarne Kvinge -// -// Copyright 2012-2015 Xamarin Inc. -// - -#include "xamarin/xamarin.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void xamarin_create_classes_Xamarin_iOS (); - -#ifdef __cplusplus -} -#endif - -void xamarin_setup_impl () -{ -#if DEBUG - xamarin_debug_mode = TRUE; -#endif - xamarin_create_classes_Xamarin_iOS (); - xamarin_marshal_managed_exception_mode = MarshalManagedExceptionModeDisable; -#if DEBUG - xamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionModeUnwindManagedCode; -#else - xamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionModeDisable; -#endif - - mono_dllmap_insert (NULL, "System.Native", NULL, "mono-native", NULL); - mono_dllmap_insert (NULL, "System.Security.Cryptography.Native.Apple", NULL, "mono-native", NULL); - mono_dllmap_insert (NULL, "System.Net.Security.Native", NULL, "mono-native", NULL); -} - -int -main (int argc, char** argv) -{ - // There's a potentially uncaught exception here, which: - // 1. only happens when/if `xamarin_initialize / ObjCRuntime.Initialize` throws a native exception. - // This should not happen (nor be ignored) since the runtime would not be fully initialized; - // 2. only happens when (non default) `MarshalManagedExceptionModeThrowObjectiveCException` is used, - // specifically asking for the native exception to be thrown; and - // 3. only happens on simulator builds (hint: filename), i.e. not on code that ships to customers; - // 4. catching the exception creates an empty/white app, which hides the issue or confuses developers. - // A crash (report) is much more useful to them (and us). - @autoreleasepool { return xamarin_main (argc, argv, XamarinLaunchModeApp); } -} - - -void xamarin_initialize_callbacks () __attribute__ ((constructor)); -void xamarin_initialize_callbacks () -{ - xamarin_setup = xamarin_setup_impl; -}