Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions runtime/monotouch-main.m
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,6 @@ - (void) memoryWarning: (NSNotification *) sender
case XamarinLaunchModeApp:
rv = mono_jit_exec (mono_domain_get (), assembly, managed_argc, managed_argv);
break;
case XamarinLaunchModeEmbedded:
// do nothing
break;
default:
xamarin_assertion_message ("Invalid launch mode: %i.", launch_mode);
break;
Expand Down
45 changes: 1 addition & 44 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@
struct MTRegistrationMap* RegistrationData;
enum MarshalObjectiveCExceptionMode MarshalObjectiveCExceptionMode;
enum MarshalManagedExceptionMode MarshalManagedExceptionMode;
#if MONOMAC
enum XamarinLaunchMode LaunchMode;
const char *EntryAssemblyPath;
#endif
struct AssemblyLocations* AssemblyLocations;
// This struct must be kept in sync with the corresponding struct in Runtime.cs, and since we use the same managed code for both MonoVM and CoreCLR,
// we can't restrict the following fields to CORECLR_RUNTIME only, we can only exclude it from legacy Xamarin.
Expand Down Expand Up @@ -1085,37 +1081,6 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
return entry->wrapper_token;
}

void
xamarin_initialize_embedded ()
{
static bool initialized = false;
if (initialized)
return;
initialized = true;

char *argv[] = { NULL };
char *libname = NULL;

Dl_info info;
if (dladdr ((void *) xamarin_initialize_embedded, &info) != 0) {
const char *last_sep = strrchr (info.dli_fname, '/');
if (last_sep == NULL) {
libname = strdup (info.dli_fname);
} else {
libname = strdup (last_sep + 1);
}
argv [0] = libname;
}

if (argv [0] == NULL)
argv [0] = (char *) "embedded";

xamarin_main (1, argv, XamarinLaunchModeEmbedded);

if (libname != NULL)
free (libname);
}

/* Installs g_print/g_error handlers that will redirect output to the system Console */
void
xamarin_install_log_callbacks ()
Expand Down Expand Up @@ -1168,10 +1133,6 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
options.Trampolines = &trampolines;
options.MarshalObjectiveCExceptionMode = xamarin_marshal_objectivec_exception_mode;
options.MarshalManagedExceptionMode = xamarin_marshal_managed_exception_mode;
#if MONOMAC
options.LaunchMode = xamarin_launch_mode;
options.EntryAssemblyPath = xamarin_entry_assembly_path;
#endif

#if defined (CORECLR_RUNTIME)
options.xamarin_objc_msgsend = (void *) xamarin_dyn_objc_msgSend;
Expand Down Expand Up @@ -1238,11 +1199,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
xamarin_assertion_message ("Could not find the main bundle in the app ([NSBundle mainBundle] returned nil)");

#if TARGET_OS_MACCATALYST || TARGET_OS_OSX
if (xamarin_launch_mode == XamarinLaunchModeEmbedded) {
bundle_path = [[[NSBundle bundleForClass: [XamarinAssociatedObject class]] bundlePath] stringByAppendingPathComponent: @"Versions/Current"];
} else {
bundle_path = [[main_bundle bundlePath] stringByAppendingPathComponent:@"Contents"];
}
bundle_path = [[main_bundle bundlePath] stringByAppendingPathComponent:@"Contents"];
bundle_path = [bundle_path stringByAppendingPathComponent: xamarin_custom_bundle_name];
#else
bundle_path = [main_bundle bundlePath];
Expand Down
2 changes: 0 additions & 2 deletions runtime/xamarin/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum MarshalManagedExceptionMode : int {
enum XamarinLaunchMode {
XamarinLaunchModeApp = 0,
XamarinLaunchModeExtension = 1,
XamarinLaunchModeEmbedded = 2,
};

// This has a managed equivalent in NSObject2.cs
Expand Down Expand Up @@ -111,7 +110,6 @@ extern bool xamarin_disable_omit_fp;
#if MONOMAC
extern bool xamarin_mac_hybrid_aot;
extern bool xamarin_mac_modern;
extern char *xamarin_entry_assembly_path;
#endif
extern bool xamarin_init_mono_debug;
extern int xamarin_log_level;
Expand Down
1 change: 0 additions & 1 deletion runtime/xamarin/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ struct AssemblyLocations {
};

void xamarin_initialize ();
void xamarin_initialize_embedded (); /* Public API, must not change - this is used by the embeddinator */

void xamarin_assertion_message (const char *msg, ...) __attribute__((__noreturn__));
// Gets the bundle path (where the managed executable is). This is *not* the path of the app bundle (.app/.appex).
Expand Down
22 changes: 1 addition & 21 deletions src/ObjCRuntime/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,6 @@ internal enum InitializationFlags : int {
IsNativeAOT = 0x40,
}

#if MONOMAC
/* This enum must always match the identical enum in runtime/xamarin/main.h */
internal enum LaunchMode : int {
App = 0,
Extension = 1,
Embedded = 2,
}
#endif

[StructLayout (LayoutKind.Sequential)]
internal unsafe struct InitializationOptions {
public int Size;
Expand All @@ -195,10 +186,6 @@ internal unsafe struct InitializationOptions {
public MTRegistrationMap* RegistrationMap;
public MarshalObjectiveCExceptionMode MarshalObjectiveCExceptionMode;
public MarshalManagedExceptionMode MarshalManagedExceptionMode;
#if MONOMAC
public LaunchMode LaunchMode;
public IntPtr EntryAssemblyPath; /* char * */
#endif
IntPtr AssemblyLocations;

public IntPtr xamarin_objc_msgsend;
Expand Down Expand Up @@ -577,16 +564,9 @@ static IntPtr PrintAllExceptions (IntPtr exception_gchandle)
return Marshal.StringToHGlobalAuto (str.ToString ());
}

// IL2026: Using member 'System.Reflection.Assembly.LoadFile(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.
[UnconditionalSuppressMessage ("", "IL2026", Justification = "We only want the entry assembly, and then we only want the entry point, which survives trimming.")]
static unsafe Assembly? GetEntryAssembly ()
{
var asm = Assembly.GetEntryAssembly ();
#if MONOMAC
if (asm is null)
asm = Assembly.LoadFile (Marshal.PtrToStringAuto (options->EntryAssemblyPath)!);
#endif
return asm;
return Assembly.GetEntryAssembly ();
}

// This method will register all assemblies referenced by the entry assembly.
Expand Down
Loading