[netcore] Fix offsets generation when cross compiling
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 25 Oct 2019 18:32:03 +0000 (20:32 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 28 Oct 2019 12:57:17 +0000 (13:57 +0100)
The offsets-tool.py uses some magic to map `typename` to `<underscore>typename` for looking up runtime types.
This caused issues on netcore because we aliased it to a different name.

To fix this let's keep the `_MonoInternalThread` name instead and just fix the one location where `_MonoThread` is used.

Commit migrated from https://github.com/mono/mono/commit/450d4746849d228c85748d9ab4ef68f90ac0c7f2

src/mono/mono/metadata/appdomain.c
src/mono/mono/metadata/object-internals.h
src/mono/mono/metadata/object.h
src/mono/mono/mini/mini-runtime.c
src/mono/mono/utils/mono-forward-internal.h

index d742b92..3da57a9 100644 (file)
@@ -440,8 +440,7 @@ mono_check_corlib_version_internal (void)
 #if defined(MONO_CROSS_COMPILE)
        /* Can't read the corlib version because we only have the target class layouts */
        return NULL;
-#endif
-
+#else
        char *result = NULL;
        char *version = mono_get_corlib_version ();
        if (!version) {
@@ -466,6 +465,7 @@ mono_check_corlib_version_internal (void)
 exit:
        g_free (version);
        return result;
+#endif
 }
 
 /**
index c737141..9847514 100644 (file)
@@ -581,15 +581,11 @@ void
 mono_gstring_append_thread_name (GString*, MonoInternalThread*);
 
 
-#ifdef ENABLE_NETCORE
 /*
- * There is only one thread object, MonoInternalThread is aliased to MonoThread,
+ * NETCORE: There is only one thread object,
  * thread->internal_thread points to itself.
  */
-struct _MonoThread {
-#else
 struct _MonoInternalThread {
-#endif
        // FIXME: Mechanize keeping this in sync with managed.
        MonoObject  obj;
        volatile int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks. Used for appdomain_ref push/pop */
@@ -632,7 +628,7 @@ struct _MonoInternalThread {
        gsize thread_state;
 
 #ifdef ENABLE_NETCORE
-       struct _MonoThread *internal_thread;
+       struct _MonoInternalThread *internal_thread;
        MonoObject *start_obj;
        MonoException *pending_exception;
 #else
@@ -645,9 +641,7 @@ struct _MonoInternalThread {
        gpointer last;
 };
 
-#ifdef ENABLE_NETCORE
-#define _MonoInternalThread _MonoThread
-#else
+#ifndef ENABLE_NETCORE
 struct _MonoThread {
        MonoObject obj;
        MonoInternalThread *internal_thread;
index 9428405..da19d3d 100644 (file)
@@ -22,7 +22,11 @@ typedef struct _MonoReflectionEvent MONO_RT_MANAGED_ATTR MonoReflectionEvent;
 typedef struct _MonoReflectionType MONO_RT_MANAGED_ATTR MonoReflectionType;
 typedef struct _MonoDelegate MONO_RT_MANAGED_ATTR MonoDelegate;
 typedef struct _MonoThreadsSync MonoThreadsSync;
+#ifdef ENABLE_NETCORE
+typedef struct _MonoInternalThread MONO_RT_MANAGED_ATTR MonoThread;
+#else
 typedef struct _MonoThread MONO_RT_MANAGED_ATTR MonoThread;
+#endif
 typedef struct _MonoDynamicAssembly MonoDynamicAssembly;
 typedef struct _MonoDynamicImage MonoDynamicImage;
 typedef struct _MonoReflectionMethodBody MONO_RT_MANAGED_ATTR MonoReflectionMethodBody;
index f00d5ba..91e1d16 100644 (file)
@@ -4770,7 +4770,9 @@ mini_cleanup (MonoDomain *domain)
        mono_runtime_cleanup (domain);
 #endif
 
+#ifndef ENABLE_NETCORE
        mono_threadpool_cleanup ();
+#endif
 
        MONO_PROFILER_RAISE (runtime_shutdown_end, ());
 
index 269f396..d5057c1 100644 (file)
@@ -14,11 +14,7 @@ typedef struct MonoHandleStack MonoHandleStack;
 typedef struct MonoJitTlsData MonoJitTlsData;
 typedef struct MonoLMF MonoLMF;
 typedef struct MonoTrampInfo MonoTrampInfo;
-#ifdef ENABLE_NETCORE
-typedef struct _MonoThread MonoInternalThread;
-#else
 typedef struct _MonoInternalThread MonoInternalThread;
-#endif
 typedef struct _SgenThreadInfo SgenThreadInfo;
 
 #endif