[XM] Fix linker ability to deadstrip library loads from NSObject.mac.… (#448)
* [XM] Fix linker ability to deadstrip library loads from NSObject.mac.cd for new libraries - Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42177 in Release / Mobile since we can rip out GameController if not used
This commit is contained in:
Родитель
413b5c2a88
Коммит
9530bdf608
|
@ -42,6 +42,7 @@ namespace XamCore.Foundation {
|
|||
// note: the linker will remove the unrequired `dlopen` calls
|
||||
// Used to force the loading of AppKit and Foundation
|
||||
// ** DO NOT rename the fields as mmp's linker can remove them when not required **
|
||||
// ** IF YOU ADD ITEMS HERE PLEASE UPDATE linker/ObjCExtensions.cs and mmp/linker/MonoMac.Tuner/MonoMacNamespaces.cs
|
||||
static IntPtr fl = Dlfcn.dlopen (Constants.FoundationLibrary, 1);
|
||||
static IntPtr al = Dlfcn.dlopen (Constants.AppKitLibrary, 1);
|
||||
static IntPtr ab = Dlfcn.dlopen (Constants.AddressBookLibrary, 1);
|
||||
|
@ -93,6 +94,7 @@ namespace XamCore.Foundation {
|
|||
static IntPtr io = Dlfcn.dlopen (Constants.ModelIOLibrary, 1);
|
||||
static IntPtr nc = Dlfcn.dlopen (Constants.NotificationCenterLibrary, 1);
|
||||
#endif
|
||||
// ** IF YOU ADD ITEMS HERE PLEASE UPDATE linker/ObjCExtensions.cs and mmp/linker/MonoMac.Tuner/MonoMacNamespaces.cs
|
||||
|
||||
#if !XAMCORE_4_0
|
||||
[Obsolete ("Use PlatformAssembly for easier code sharing across platforms")]
|
||||
|
|
|
@ -28,7 +28,36 @@ namespace Xamarin.Linker {
|
|||
ObjCRuntime = profile.GetNamespace ("ObjCRuntime");
|
||||
Security = profile.GetNamespace ("Security");
|
||||
StoreKit = profile.GetNamespace ("StoreKit");
|
||||
GameController = profile.GetNamespace ("GameController");
|
||||
JavaScriptCore = profile.GetNamespace ("JavaScriptCore");
|
||||
CoreAudioKit = profile.GetNamespace ("CoreAudioKit");
|
||||
InputMethodKit = profile.GetNamespace ("InputMethodKit");
|
||||
OpenAL = profile.GetNamespace ("OpenAL");
|
||||
MediaAccessibility = profile.GetNamespace ("MediaAccessibility");
|
||||
CoreMIDI = profile.GetNamespace ("CoreMIDI");
|
||||
MediaLibrary = profile.GetNamespace ("MediaLibrary");
|
||||
GLKit = profile.GetNamespace ("GLKit");
|
||||
SpriteKit = profile.GetNamespace ("SpriteKit");
|
||||
CloudKit = profile.GetNamespace ("CloudKit");
|
||||
LocalAuthentication = profile.GetNamespace ("LocalAuthentication");
|
||||
Accounts = profile.GetNamespace ("Accounts");
|
||||
Contacts = profile.GetNamespace ("Contacts");
|
||||
ContactsUI = profile.GetNamespace ("ContactsUI");
|
||||
MapKit = profile.GetNamespace ("MapKit");
|
||||
EventKit = profile.GetNamespace ("EventKit");
|
||||
Social = profile.GetNamespace ("Social");
|
||||
AVKit = profile.GetNamespace ("AVKit");
|
||||
VideoToolbox = profile.GetNamespace ("VideoToolbox");
|
||||
GameplayKit = profile.GetNamespace ("GameplayKit");
|
||||
NetworkExtension = profile.GetNamespace ("NetworkExtension");
|
||||
MultipeerConnectivity = profile.GetNamespace ("MultipeerConnectivity");
|
||||
MetalKit = profile.GetNamespace ("MetalKit");
|
||||
ModelIO = profile.GetNamespace ("ModelIO");
|
||||
#if MONOMAC
|
||||
IOBluetooth = profile.GetNamespace ("IOBluetooth");
|
||||
IOBluetoothUI = profile.GetNamespace ("IOBluetoothUI");
|
||||
FinderSync = profile.GetNamespace ("FinderSync");
|
||||
NotificationCenter = profile.GetNamespace ("NotificationCenter");
|
||||
AppKit = profile.GetNamespace ("AppKit");
|
||||
CoreWlan = profile.GetNamespace ("CoreWlan");
|
||||
ImageKit = profile.GetNamespace ("ImageKit");
|
||||
|
@ -44,6 +73,31 @@ namespace Xamarin.Linker {
|
|||
#endif
|
||||
}
|
||||
|
||||
public static string JavaScriptCore { get; private set; }
|
||||
public static string CoreAudioKit { get; private set; }
|
||||
public static string InputMethodKit { get; private set; }
|
||||
public static string OpenAL { get; private set; }
|
||||
public static string MediaAccessibility { get; private set; }
|
||||
public static string CoreMIDI { get; private set; }
|
||||
public static string MediaLibrary { get; private set; }
|
||||
public static string GLKit { get; private set; }
|
||||
public static string SpriteKit { get; private set; }
|
||||
public static string CloudKit { get; private set; }
|
||||
public static string LocalAuthentication { get; private set; }
|
||||
public static string Accounts { get; private set; }
|
||||
public static string Contacts { get; private set; }
|
||||
public static string ContactsUI { get; private set; }
|
||||
public static string MapKit { get; private set; }
|
||||
public static string EventKit { get; private set; }
|
||||
public static string Social { get; private set; }
|
||||
public static string AVKit { get; private set; }
|
||||
public static string VideoToolbox { get; private set; }
|
||||
public static string GameplayKit { get; private set; }
|
||||
public static string NetworkExtension { get; private set; }
|
||||
public static string MultipeerConnectivity { get; private set; }
|
||||
public static string MetalKit { get; private set; }
|
||||
public static string ModelIO { get; private set; }
|
||||
|
||||
public static string AddressBook { get; private set; }
|
||||
|
||||
public static string AVFoundation { get; private set; }
|
||||
|
@ -61,6 +115,8 @@ namespace Xamarin.Linker {
|
|||
public static string Foundation { get; private set; }
|
||||
|
||||
public static string GameKit { get; private set; }
|
||||
|
||||
public static string GameController { get; private set; }
|
||||
|
||||
public static string ObjCRuntime { get; private set; }
|
||||
|
||||
|
@ -69,6 +125,11 @@ namespace Xamarin.Linker {
|
|||
public static string StoreKit { get; private set; }
|
||||
|
||||
#if MONOMAC
|
||||
public static string IOBluetooth { get; private set; }
|
||||
public static string IOBluetoothUI { get; private set; }
|
||||
public static string FinderSync { get; private set; }
|
||||
public static string NotificationCenter { get; private set; }
|
||||
|
||||
public static string AppKit { get; private set; }
|
||||
|
||||
public static string CoreWlan { get; private set; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2012-2013 Xamarin Inc. All rights reserved.
|
||||
//#define DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -15,6 +16,56 @@ namespace MonoMac.Tuner {
|
|||
|
||||
public class MonoMacNamespaces : IStep {
|
||||
|
||||
Dictionary <string, string> NamespaceMapping = new Dictionary <string, string> {
|
||||
{ Constants.FoundationLibrary, Namespaces.Foundation },
|
||||
{ Constants.AppKitLibrary, Namespaces.AppKit },
|
||||
{ Constants.AddressBookLibrary, Namespaces.AddressBook },
|
||||
{ Constants.CoreTextLibrary, Namespaces.CoreText },
|
||||
{ Constants.WebKitLibrary, Namespaces.WebKit },
|
||||
{ Constants.QuartzLibrary, Namespaces.CoreAnimation },
|
||||
{ Constants.QTKitLibrary, Namespaces.QTKit },
|
||||
{ Constants.CoreLocationLibrary, Namespaces.CoreLocation },
|
||||
{ Constants.SecurityLibrary, Namespaces.Security },
|
||||
{ Constants.QuartzComposerLibrary, Namespaces.QuartzComposer },
|
||||
{ Constants.CoreWlanLibrary, Namespaces.CoreWlan },
|
||||
{ Constants.PdfKitLibrary, Namespaces.PdfKit },
|
||||
{ Constants.ImageKitLibrary, Namespaces.ImageKit },
|
||||
{ Constants.ScriptingBridgeLibrary, Namespaces.ScriptingBridge },
|
||||
{ Constants.AVFoundationLibrary, Namespaces.AVFoundation },
|
||||
{ Constants.CoreBluetoothLibrary, Namespaces.CoreBluetooth },
|
||||
{ Constants.GameKitLibrary, Namespaces.GameKit },
|
||||
{ Constants.GameControllerLibrary, Namespaces.GameController },
|
||||
{ Constants.JavaScriptCoreLibrary, Namespaces.JavaScriptCore },
|
||||
{ Constants.CoreAudioKitLibrary, Namespaces.CoreAudioKit },
|
||||
{ Constants.InputMethodKitLibrary, Namespaces.InputMethodKit },
|
||||
{ Constants.OpenALLibrary, Namespaces.OpenAL },
|
||||
{ Constants.MediaAccessibilityLibrary, Namespaces.MediaAccessibility },
|
||||
{ Constants.CoreMidiLibrary, Namespaces.CoreMIDI },
|
||||
{ Constants.MediaLibraryLibrary, Namespaces.MediaLibrary },
|
||||
{ Constants.GLKitLibrary, Namespaces.GLKit },
|
||||
{ Constants.SpriteKitLibrary, Namespaces.SpriteKit },
|
||||
{ Constants.CloudKitLibrary, Namespaces.CloudKit },
|
||||
{ Constants.LocalAuthenticationLibrary, Namespaces.LocalAuthentication },
|
||||
{ Constants.AccountsLibrary, Namespaces.Accounts },
|
||||
{ Constants.ContactsLibrary, Namespaces.Contacts },
|
||||
{ Constants.ContactsUILibrary, Namespaces.ContactsUI },
|
||||
{ Constants.MapKitLibrary, Namespaces.MapKit },
|
||||
{ Constants.EventKitLibrary, Namespaces.EventKit },
|
||||
{ Constants.SocialLibrary, Namespaces.Social },
|
||||
{ Constants.AVKitLibrary, Namespaces.AVKit },
|
||||
{ Constants.VideoToolboxLibrary, Namespaces.VideoToolbox },
|
||||
{ Constants.GameplayKitLibrary, Namespaces.GameplayKit },
|
||||
{ Constants.NetworkExtensionLibrary, Namespaces.NetworkExtension },
|
||||
{ Constants.MultipeerConnectivityLibrary, Namespaces.MultipeerConnectivity },
|
||||
{ Constants.MetalKitLibrary, Namespaces.MetalKit },
|
||||
{ Constants.ModelIOLibrary, Namespaces.ModelIO },
|
||||
{ Constants.IOBluetoothLibrary, Namespaces.IOBluetooth },
|
||||
{ Constants.IOBluetoothUILibrary, Namespaces.IOBluetoothUI },
|
||||
{ Constants.FinderSyncLibrary, Namespaces.FinderSync },
|
||||
{ Constants.NotificationCenterLibrary, Namespaces.NotificationCenter },
|
||||
{ Constants.SceneKitLibrary, Namespaces.SceneKit },
|
||||
{ Constants.StoreKitLibrary, Namespaces.StoreKit } };
|
||||
|
||||
public void Process (LinkContext context)
|
||||
{
|
||||
var profile = (Profile.Current as BaseProfile);
|
||||
|
@ -43,92 +94,18 @@ namespace MonoMac.Tuner {
|
|||
// only when we know the namespace is not being used by the app
|
||||
// Based on the list from xamcore/src/Foundation/NSObjectMac.cs
|
||||
bool remove_dlopen = false;
|
||||
switch (ins.Operand as string) {
|
||||
case Constants.FoundationLibrary:
|
||||
// note: every app has Foundation - even if I could not find a sample that required it pre-loaded
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.Foundation);
|
||||
break;
|
||||
case Constants.AppKitLibrary:
|
||||
// note: every app has AppKit - even if I could not find a sample that required it pre-loaded
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.AppKit);
|
||||
break;
|
||||
case Constants.AddressBookLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.AddressBook);
|
||||
break;
|
||||
case Constants.CoreTextLibrary:
|
||||
// FIXME: CoreTextArcMonoMac does not need it (i.e. maybe we could always remove it)
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.CoreText);
|
||||
break;
|
||||
case Constants.WebKitLibrary:
|
||||
// WhereIsMyMac sample won't work without it
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.WebKit);
|
||||
break;
|
||||
case Constants.QuartzLibrary:
|
||||
// FIXME: AnimatedClock does not need it (i.e. maybe we could always remove it)
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.CoreAnimation);
|
||||
break;
|
||||
case Constants.QTKitLibrary:
|
||||
// QTRecorder sample won't work without it
|
||||
// StillMotion sample won't work without it
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.QTKit);
|
||||
break;
|
||||
case Constants.CoreLocationLibrary:
|
||||
// WhereIsMyMac sample won't work without it
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.CoreLocation);
|
||||
break;
|
||||
case Constants.SecurityLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.Security);
|
||||
break;
|
||||
case Constants.QuartzComposerLibrary:
|
||||
// CAQuartzComposition sample won't work without it
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.QuartzComposer);
|
||||
break;
|
||||
case Constants.CoreWlanLibrary:
|
||||
// CoreWLANWirelessManager sample won't work without it
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.CoreWlan);
|
||||
break;
|
||||
case Constants.PdfKitLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.PdfKit);
|
||||
break;
|
||||
case Constants.ImageKitLibrary:
|
||||
// ImageKitDemo sample won't work without it
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.ImageKit);
|
||||
break;
|
||||
case Constants.ScriptingBridgeLibrary:
|
||||
// no working (attic) sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.ScriptingBridge);
|
||||
break;
|
||||
case Constants.AVFoundationLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.AVFoundation);
|
||||
break;
|
||||
case Constants.CoreBluetoothLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.CoreBluetooth);
|
||||
break;
|
||||
case Constants.GameKitLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.GameKit);
|
||||
break;
|
||||
case Constants.SceneKitLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.SceneKit);
|
||||
break;
|
||||
case Constants.StoreKitLibrary:
|
||||
// no sample
|
||||
remove_dlopen = !namespaces.Contains (Namespaces.StoreKit);
|
||||
break;
|
||||
|
||||
string targetNamespace;
|
||||
if (NamespaceMapping.TryGetValue (ins.Operand as string, out targetNamespace)) {
|
||||
remove_dlopen = !namespaces.Contains (targetNamespace);
|
||||
}
|
||||
#if DEBUG
|
||||
default:
|
||||
else {
|
||||
string libname = ins.Operand as string;
|
||||
if (libname.StartsWith ("/", StringComparison.Ordinal))
|
||||
Console.WriteLine ("Unprocessed library / namespace {0}", libname);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (remove_dlopen) {
|
||||
FieldDefinition f = Nop (ins);
|
||||
|
|
Загрузка…
Ссылка в новой задаче