[Mono-dev] Status of non-full AOT on x86 mac

Brian Luczkiewicz brian at sooloos.com
Sat Oct 30 23:15:32 EDT 2010


Hello,


> Could you post the patch for review and license it under the MIT X11
> license?
>
> Miguel
>


I've reproduced the patch below.

The following patch is released under the terms of the MIT/X11 license, per
Miguel's request.

Brian


commit fb96f5d6387cc5c019fc00bfc89a25204fa14166
Author: Brian Luczkiewicz <brian at sooloos.com>
Date:   Sat Oct 30 21:52:09 2010 -0400

    Enable --aot (but not --aot=full) on osx/x86

diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c
index 5088324..70ff8c0 100644
--- a/mono/mini/aot-compiler.c
+++ b/mono/mini/aot-compiler.c
@@ -82,6 +82,8 @@
 #define SHARED_EXT ".dll"
 #elif defined(__ppc__) && defined(__MACH__)
 #define SHARED_EXT ".dylib"
+#elif defined(__APPLE__) && defined(TARGET_X86) &&
!defined(__native_client_codegen__)
+#define SHARED_EXT ".dylib"
 #else
 #define SHARED_EXT ".so"
 #endif
@@ -6055,6 +6057,8 @@ compile_asm (MonoAotCompile *acfg)
 #define LD_OPTIONS "-m elf64ppc"
 #elif defined(sparc) && SIZEOF_VOID_P == 8
 #define AS_OPTIONS "-xarch=v9"
+#elif defined(TARGET_X86) && defined(__APPLE__) &&
!defined(__native_client_codegen__)
+#define AS_OPTIONS "-arch i386 -W"
 #else
 #define AS_OPTIONS ""
 #endif
@@ -6120,6 +6124,8 @@ compile_asm (MonoAotCompile *acfg)
  command = g_strdup_printf ("gcc -dynamiclib -o %s %s.o", tmp_outfile_name,
acfg->tmpfname);
 #elif defined(HOST_WIN32)
  command = g_strdup_printf ("gcc -shared --dll -mno-cygwin -o %s %s.o",
tmp_outfile_name, acfg->tmpfname);
+#elif defined(TARGET_X86) && defined(__APPLE__) &&
!defined(__native_client_codegen__)
+ command = g_strdup_printf ("gcc -m32 -dynamiclib -o %s %s.o",
tmp_outfile_name, acfg->tmpfname);
 #else
  command = g_strdup_printf ("%sld %s %s -shared -o %s %s.o", tool_prefix,
EH_LD_OPTIONS, LD_OPTIONS, tmp_outfile_name, acfg->tmpfname);
 #endif
diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c
index 4bae87b..d27d44c 100644
--- a/mono/mini/aot-runtime.c
+++ b/mono/mini/aot-runtime.c
@@ -65,6 +65,8 @@
 #define SHARED_EXT ".dll"
 #elif ((defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__)) ||
defined(__MACH__)) && !defined(__linux__)
 #define SHARED_EXT ".dylib"
+#elif defined(__APPLE__) && defined(TARGET_X86) &&
!defined(__native_client_codegen__)
+#define SHARED_EXT ".dylib"
 #else
 #define SHARED_EXT ".so"
 #endif
diff --git a/mono/mini/image-writer.c b/mono/mini/image-writer.c
index ff7e3d8..4a3cf02 100644
--- a/mono/mini/image-writer.c
+++ b/mono/mini/image-writer.c
@@ -113,7 +113,7 @@
 #define USE_ELF_RELA 1
 #endif

-#if defined(TARGET_X86) && !defined(TARGET_WIN32)
+#if defined(TARGET_X86) && !defined(TARGET_WIN32) && !defined(__APPLE__)
 #define USE_ELF_WRITER 1
 #endif

@@ -1576,7 +1576,7 @@ static void
 asm_writer_emit_global (MonoImageWriter *acfg, const char *name, gboolean
func)
 {
  asm_writer_emit_unset_mode (acfg);
-#if  (defined(__ppc__) && defined(TARGET_ASM_APPLE)) ||
(defined(HOST_WIN32) && !defined(MONO_CROSS_COMPILE))
+#if  ((defined(__ppc__) || defined(TARGET_X86)) &&
defined(TARGET_ASM_APPLE)) || (defined(HOST_WIN32) &&
!defined(MONO_CROSS_COMPILE))
     // mach-o always uses a '_' prefix.
  fprintf (acfg->fp, "\t.globl _%s\n", name);
 #else
@@ -1612,7 +1612,13 @@ static void
 asm_writer_emit_label (MonoImageWriter *acfg, const char *name)
 {
  asm_writer_emit_unset_mode (acfg);
-#if defined(HOST_WIN32) && (defined(TARGET_X86) || defined(TARGET_AMD64))
+#if (defined(TARGET_X86) && defined(TARGET_ASM_APPLE))
+        name = get_label(name);
+        fprintf (acfg->fp, "%s:\n", name);
+        if (name[0] != 'L')
+            fprintf (acfg->fp, "_%s:\n", name);
+
+#elif (defined(HOST_WIN32) && (defined(TARGET_X86) ||
defined(TARGET_AMD64))) || (defined(TARGET_X86) &&
defined(TARGET_ASM_APPLE))
  fprintf (acfg->fp, "_%s:\n", name);
 #if defined(HOST_WIN32)
  /* Emit a normal label too */
diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h
index 260e557..385a930 100644
--- a/mono/mini/mini-x86.h
+++ b/mono/mini/mini-x86.h
@@ -285,7 +285,9 @@ typedef struct {
 #define MONO_ARCH_MONITOR_OBJECT_REG X86_EAX
 #endif
 #define MONO_ARCH_HAVE_STATIC_RGCTX_TRAMPOLINE 1
+#if !defined (__APPLE__) || defined(__native_client_codegen__)
 #define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1
+#endif
 #define MONO_ARCH_GOT_REG X86_EBX
 #define MONO_ARCH_HAVE_GET_TRAMPOLINES 1

@@ -297,9 +299,7 @@ typedef struct {

 #define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1

-#if !defined(__APPLE__) || defined(__native_client_codegen__)
 #define MONO_ARCH_AOT_SUPPORTED 1
-#endif

 #if defined(__linux__) || defined(__sun)
 #define MONO_ARCH_ENABLE_MONITOR_IL_FASTPATH 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20101030/7d33efba/attachment-0001.html 


More information about the Mono-devel-list mailing list