
On 12/06/2011 20:17, Jason Dagit wrote:
On Sun, Jun 12, 2011 at 11:45 AM, Brandon Allbery
wrote: On Sun, Jun 12, 2011 at 14:31, Jason Dagit
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][2].
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 cannot do.
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). Cheers, Simon