Bug 2106 - OSX mono bundle enabled with LLVM, however fails to load libmono-llvm
Summary: OSX mono bundle enabled with LLVM, however fails to load libmono-llvm
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-11-20 21:27 UTC by Jonathan Shore
Modified: 2011-12-22 12:47 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jonathan Shore 2011-11-20 21:27:55 UTC
The OSX mono dmg, either separately or with the latest MonoDevelop has an issue with LLVM.  LLVM is enabled, however, get the following error:

$ mono -llvm TestNumericalPerformance.exe 
llvm load failed: dlopen(libmono-llvm.bundle, 9): image not found

Mono Warning: llvm support could not be loaded.
...

Could future builds of mono for the make use a statically compiled llvm library to avoid DLL issues like this?  I am able to find the dylib in /Library/Frameworks/Mono.framework/Libraries and even put that in the DYLD_LIBRARY_PATH path.   However problem persists.

I'm just using a standard install on OSX Lion.  Nothing custom.
Comment 1 Suzanne Martin 2011-12-22 11:08:49 UTC
I have had the same problem for a while; however, after installing 2.10.8 recently, I have been able to work around it by setting DYLD_LIBRARY_PATH explicitly. I am using Snow Leopard, though,  so DYLD_LIBRARY_PATH not working may be a Lion-specific issue.

I am using the following script to run Mono:

#!/bin/sh
export DYLD_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Libraries
exec /usr/bin/mono "$@"

Have you tried using dtruss to track down in which locations Mono is looking for libmono-llvm?
Comment 2 Duncan Mak 2011-12-22 11:29:23 UTC
I think the recommended practice is to set DYLD_FALLBACK_LIBRARY_PATH and not DYLD_LIBRARY_PATH.

For now, this is the current recommended workaround for enabling LLVM.

DYLD_FALLBACK_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib mono --llvm hello.exe

We will be looking into making this easier in one of the upcoming releases.
Comment 3 Jonathan Shore 2011-12-22 11:39:08 UTC
Neither of those env variables worked for me.  Same problem.

FYI, mono is looking in the following locations, all appropriate for a linux build, but not for a framework.   I'm guessing that the canonical build targets /usr/local and then is packaged up for a Frameworks install.

readlink("/proc/self/exe\0", 0xBFFFE7BC, 0xFFF)          = -1 Err#2
stat64("libmono-llvm\0", 0xBFFFD8D0, 0xFFF)              = -1 Err#2
stat64("/var/root/lib/libmono-llvm\0", 0xBFFFE090, 0xFFF)                = -1 Err#2
stat64("/usr/local/lib/libmono-llvm\0", 0xBFFFE090, 0xFFF)               = -1 Err#2
stat64("/usr/lib/libmono-llvm\0", 0xBFFFE0A0, 0xFFF)             = -1 Err#2
open_nocancel("libmono-llvm.la\0", 0x20000, 0x0)                 = -1 Err#2
stat64("libmono-llvm.dylib\0", 0xBFFFD8D0, 0x0)          = -1 Err#2
stat64("/var/root/lib/libmono-llvm.dylib\0", 0xBFFFE090, 0x0)            = -1 Err#2
stat64("/usr/local/lib/libmono-llvm.dylib\0", 0xBFFFE090, 0x0)           = -1 Err#2
stat64("/usr/lib/libmono-llvm.dylib\0", 0xBFFFE090, 0x0)                 = -1 Err#2
open_nocancel("libmono-llvm.dylib.la\0", 0x20000, 0x0)           = -1 Err#2
stat64("libmono-llvm.so\0", 0xBFFFD8D0, 0x0)             = -1 Err#2
stat64("/var/root/lib/libmono-llvm.so\0", 0xBFFFE090, 0x0)               = -1 Err#2
stat64("/usr/local/lib/libmono-llvm.so\0", 0xBFFFE090, 0x0)              = -1 Err#2
stat64("/usr/lib/libmono-llvm.so\0", 0xBFFFE0A0, 0x0)            = -1 Err#2
open_nocancel("libmono-llvm.so.la\0", 0x20000, 0x0)              = -1 Err#2
stat64("libmono-llvm.bundle\0", 0xBFFFD8D0, 0x0)                 = -1 Err#2
stat64("/var/root/lib/libmono-llvm.bundle\0", 0xBFFFE090, 0x0)           = -1 Err#2
stat64("/usr/local/lib/libmono-llvm.bundle\0", 0xBFFFE090, 0x0)          = -1 Err#2
stat64("/usr/lib/libmono-llvm.bundle\0", 0xBFFFE090, 0x0)                = -1 Err#2
open_nocancel("libmono-llvm.bundle.la\0", 0x20000, 0x0)          = -1 Err#2
fstat64(0x1, 0xBFFFDD60, 0x0)            = 0 0
write_nocancel(0x2, "Mono Warning: llvm support could not be loaded.\n@\004\211\0", 0x30)                = 48 0
Comment 4 Duncan Mak 2011-12-22 11:41:00 UTC
Jonathan - which version of Mono are you running? The latest stable version is 2.10.8.
Comment 5 Jonathan Shore 2011-12-22 11:50:27 UTC
So I added a symbolic link from the libmono-llvm.dylib to /usr/local/lib (which is in mono's search path).  It does find the lib, opens it, reads the header, then closes it.   I think it is rejecting the library.  Perhaps there is some incompatibility in the compilation for Lion?   I have a close-to-virgin Lion install, as recently rebuilt this machine.   I've added xcode & mono stuff, and the ports project git, otherwise clean.

Here are the telltails in the dtruss log.

* Found it *
stat64("/usr/local/lib/libmono-llvm.dylib\0", 0xBFFFE090, 0x0)           = 0 0

* Opened it, read header, rejected? or just determining if good library? *
open("/usr/local/lib/libmono-llvm.dylib\0", 0x0, 0x0)            = 3 0
pread(0x3, "\316\372\355\376\a\0", 0x1000, 0x0)          = 4096 0
mmap(0x468000, 0x1A000, 0x1, 0x12, 0x3, 0x30)            = 0x468000 0
mmap(0x482000, 0x1000, 0x3, 0x12, 0x3, 0x30)             = 0x482000 0
mmap(0x483000, 0xC940, 0x1, 0x12, 0x3, 0x30)             = 0x483000 0
close(0x3)               = 0 0

* libgcc load *
stat64("/usr/lib/libgcc_s.1.dylib\0", 0xBFFFD730, 0x1)           = 0 0
munmap(0x482000, 0x1000)                 = 0 0
munmap(0x483000, 0xD000)                 = 0 0
munmap(0x468000, 0x1A000)                = 0 0

open_nocancel("libmono-llvm.dylib.la\0", 0x20000, 0x0)           = -1 Err#2

* Is it continuing on the search path because did not like the prior opened? *
stat64("libmono-llvm.so\0", 0xBFFFD8D0, 0x0)             = -1 Err#2

* Further search *
stat64("/var/root/lib/libmono-llvm.so\0", 0xBFFFE090, 0x0)               = -1 Err#2
stat64("/usr/local/lib/libmono-llvm.so\0", 0xBFFFE090, 0x0)              = -1 Err#2
stat64("/usr/lib/libmono-llvm.so\0", 0xBFFFE0A0, 0x0)            = -1 Err#2
open_nocancel("libmono-llvm.so.la\0", 0x20000, 0x0)              = -1 Err#2
stat64("libmono-llvm.bundle\0", 0xBFFFD8D0, 0x0)                 = -1 Err#2
stat64("/var/root/lib/libmono-llvm.bundle\0", 0xBFFFE090, 0x0)           = -1 Err#2
stat64("/usr/local/lib/libmono-llvm.bundle\0", 0xBFFFE090, 0x0)          = -1 Err#2
stat64("/usr/lib/libmono-llvm.bundle\0", 0xBFFFE090, 0x0)                = -1 Err#2
open_nocancel("libmono-llvm.bundle.la\0", 0x20000, 0x0)          = -1 Err#2
fstat64(0x1, 0xBFFFDD60, 0x0)            = 0 0
write_nocancel(0x2, "Mono Warning: llvm support could not be loaded.\n\200$\b\0", 0x30)          = 48 0
Comment 6 Jonathan Shore 2011-12-22 11:51:01 UTC
I'm runniong 2.10.6.   I can try 2.10.8 and let you know if has the same problems ...
Comment 7 Jonathan Shore 2011-12-22 12:47:27 UTC
this looks to be working in 2.10.8.   Thanks