[Haskell-cafe] OSX, ghci, dylib, what is the correct way?
marlowsd at gmail.com
Tue Jun 14 13:26:23 CEST 2011
On 12/06/2011 20:17, Jason Dagit wrote:
> On Sun, Jun 12, 2011 at 11:45 AM, Brandon Allbery<allbery.b at gmail.com> wrote:
>> On Sun, Jun 12, 2011 at 14:31, Jason Dagit<dagitj at gmail.com> wrote:
>>> If I build the C library as a .a, then ghci comlains that it cannot
>>> open the .dylib. My first question is: Why does ghci need a .dylib
>>> and does it really use it?
>> Static libraries are... static. ghci would have to rebuild itself
>> against the static archive to use it; that's how static archives work.
>> Dynamic libraries are dynamic because they can be loaded at runtime
>> instead of compile time.
> Interesting. When I use dtruss to see what files ghci opens, it
> definitely opens .a files. That gave me the impression it knows how
> to open a .a and use it at run-time.
GHC as of version 7.0 can load .a files into GHCi.
>>> When I build a dylib I get a [segfault when loading the code into ghci].
I don't know what the cause of that is - when you load a .dylib into
GHCi, the normal system dynamic linker is used.
>> I believe ghci still uses its own dynamic loader instead of the
>> standard library one,
Only to load .o and .a files, which the normal system dynamic linker
>>  http://hackage.haskell.org/trac/ghc/ticket/4244
It would be nice to be able to use the system dynamic linker as an
alternative to our own linker, particularly to ease porting to new
platforms. However, that requires generating dynamically-linkable code
from GHC (and doing so by default, which has performance implications).
More information about the Haskell-Cafe