Merge pull request #3522 from henricm/fix-csharp-compiler-path-windows
[mono.git] / mono / mini / driver.c
index 1a7b15b6f55ad75f301e44531a82e8714d3c280d..a6d2bd117b1f75181421b9e0b65ddb23265e5fd7 100644 (file)
@@ -52,6 +52,7 @@
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/mono-hwcap.h"
 #include "mono/utils/mono-logger-internals.h"
+#include "mono/utils/w32handle.h"
 
 #include "mini.h"
 #include "jit.h"
@@ -1026,18 +1027,27 @@ mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[
        }
        
        if (mono_llvm_only) {
-               MonoObject *exc;
+               MonoObject *exc = NULL;
                int res;
 
-               res = mono_runtime_run_main (method, argc, argv, &exc);
+               res = mono_runtime_try_run_main (method, argc, argv, &exc);
                if (exc) {
                        mono_unhandled_exception (exc);
                        mono_invoke_unhandled_exception_hook (exc);
-                       return 1;
+                       g_assert_not_reached ();
                }
                return res;
        } else {
-               return mono_runtime_run_main (method, argc, argv, NULL);
+               int res = mono_runtime_run_main_checked (method, argc, argv, &error);
+               if (!is_ok (&error)) {
+                       MonoException *ex = mono_error_convert_to_exception (&error);
+                       if (ex) {
+                               mono_unhandled_exception (&ex->object);
+                               mono_invoke_unhandled_exception_hook (&ex->object);
+                               g_assert_not_reached ();
+                       }
+               }
+               return res;
        }
 }
 
@@ -1358,30 +1368,6 @@ static const char info[] =
 #define error_if_aot_unsupported()
 #endif
 
-#ifdef HOST_WIN32
-BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
-{
-       if (!mono_gc_dllmain (module_handle, reason, reserved))
-               return FALSE;
-
-       switch (reason)
-       {
-       case DLL_PROCESS_ATTACH:
-               mono_install_runtime_load (mini_init);
-               break;
-       case DLL_PROCESS_DETACH:
-               if (coree_module_handle)
-                       FreeLibrary (coree_module_handle);
-               break;
-       case DLL_THREAD_DETACH:
-               mono_thread_info_detach ();
-               break;
-       
-       }
-       return TRUE;
-}
-#endif
-
 static gboolean enable_debugging;
 
 /*
@@ -1762,6 +1748,7 @@ mono_main (int argc, char* argv[])
                } else if (strcmp (argv [i], "--llvmonly") == 0) {
                        mono_aot_only = TRUE;
                        mono_llvm_only = TRUE;
+               } else if (strcmp (argv [i], "--hybrid-aot") == 0) {
                } else if (strcmp (argv [i], "--print-vtable") == 0) {
                        mono_print_vtable = TRUE;
                } else if (strcmp (argv [i], "--stats") == 0) {
@@ -1977,6 +1964,10 @@ mono_main (int argc, char* argv[])
 
        mono_counters_init ();
 
+#ifndef HOST_WIN32
+       mono_w32handle_init ();
+#endif
+
        /* Set rootdir before loading config */
        mono_set_rootdir ();