Load the llvm module from the lib dir of an installed mono before the system dirs.
authorPaolo Molaro <lupus@oddwiz.org>
Tue, 10 Apr 2012 15:04:41 +0000 (17:04 +0200)
committerPaolo Molaro <lupus@oddwiz.org>
Tue, 10 Apr 2012 15:07:38 +0000 (17:07 +0200)
Get the executable binary name on OSX, too.
Fix private symbol use in mini-llvm.c.

mono/mini/Makefile.am
mono/mini/mini-llvm.c
mono/mini/mini-llvm.h

index 7be273943ef95c312e40392644af360070fca12b..eee3604facaca452b4855348613a1d4dff035221 100644 (file)
@@ -137,7 +137,7 @@ lib_LTLIBRARIES += libmono-llvm.la
 libmono_llvm_la_SOURCES = mini-llvm.c mini-llvm-cpp.cpp
 libmono_llvm_la_LIBADD = $(LLVM_LIBS) $(LLVM_LDFLAGS)
 if PLATFORM_DARWIN
-libmono_llvm_la_LDFLAGS=-undefined suppress
+libmono_llvm_la_LDFLAGS=-Wl,-undefined -Wl,suppress -Wl,-flat_namespace
 else
 libmono_llvm_la_LIBADD += $(top_builddir)/mono/mini/libmono-$(API_VER).la $(libs)
 endif
index dae43f06b77a75ebf602244ca16f36f29dd4004f..2c4e80782ff39321df53be457883452c18282c47 100644 (file)
@@ -4589,7 +4589,7 @@ mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call)
                switch (ainfo->storage) {
                case LLVMArgInIReg:
                case LLVMArgInFPReg: {
-                       MonoType *t = (sig->hasthis && i == 0) ? &mono_defaults.int_class->byval_arg : sig->params [i - sig->hasthis];
+                       MonoType *t = (sig->hasthis && i == 0) ? &mono_get_intptr_class ()->byval_arg : sig->params [i - sig->hasthis];
 
                        if (!t->byref && (t->type == MONO_TYPE_R8 || t->type == MONO_TYPE_R4)) {
                                MONO_INST_NEW (cfg, ins, OP_FMOVE);
index ce973673b167130b3c3568526ac7985e724a7f9e..aa99f26c8d3968c9c109a766a2656089de0c0b63 100644 (file)
@@ -7,6 +7,11 @@
 int mono_llvm_load (const char* bpath) MONO_INTERNAL;
 
 #ifdef MONO_LLVM_IN_MINI
+
+#ifdef __MACH__
+#include <mach-o/dyld.h>
+#endif
+
 typedef void (*MonoLLVMVoidFunc)(void);
 typedef void (*MonoLLVMCFGFunc)(MonoCompile *cfg);
 typedef void (*MonoLLVMEmitCallFunc)(MonoCompile *cfg, MonoCallInst *call);
@@ -91,16 +96,31 @@ mono_llvm_load (const char* bpath)
        char buf [4096];
        int binl;
        binl = readlink ("/proc/self/exe", buf, sizeof (buf)-1);
+#ifdef __MACH__
+       if (binl == -1) {
+               uint32_t bsize = sizeof (buf);
+               if (_NSGetExecutablePath (buf, &bsize) == 0) {
+                       binl = strlen (buf);
+               }
+       }
+#endif
        if (binl != -1) {
                char *base;
                char *name;
                buf [binl] = 0;
                base = g_path_get_dirname (buf);
                name = g_strdup_printf ("%s/.libs", base);
-               g_free (base);
                err = NULL;
                llvm_lib = try_llvm_load (name, &err);
                g_free (name);
+               if (!llvm_lib) {
+                       char *newbase = g_path_get_dirname (base);
+                       name = g_strdup_printf ("%s/lib", newbase);
+                       err = NULL;
+                       llvm_lib = try_llvm_load (name, &err);
+                       g_free (name);
+               }
+               g_free (base);
        }
        if (!llvm_lib) {
                llvm_lib = try_llvm_load (NULL, &err);