Dynamic loading problem

Simon Marlow simonmar at microsoft.com
Fri Apr 30 18:36:07 EDT 2004

On 30 April 2004 11:26, Duncan Coutts wrote:

> Could someone remind me what the remaining issues are in getting ghc
> to build Haskell modules/packaged into unix .so shared libraries?
> As I recall it seems to nearly work. Andre Pang got them to load and
> function but it was a bit fragile and the rts would complain after a
> short while:

It might be possible to do this, but only if you want to do
dlopen()-style linking at runtime.  Linking a haskell binary against
Haskell .so libraries still isn't possible - I had another look at this
recently, and although one of the obstacles has been removed, there are
others (details available on request).

Any remaining issues to do with dlopen()ing a Haskell .so library are
probably to do with CAFs.  The dynamically loaded code needs to call
newDynCAF() instead of newCAF() in a CAF's entry code - this is normally
arranged by the RTS linker, but for a .so you'll have to do it some
other way, like getting the compiler to emit the different call, or
doing some CPP magic (but only for -fvia-C).  Any reasonable patches to
implement this will be incorporated.

Oh, and strictly speaking we should run the __stginit_Foo() function
from each dynamically loaded module.  But the RTS linker still doesn't
do this.


More information about the Glasgow-haskell-users mailing list