
Hi, by using the RTS I've made it possible to dynamically load modules for quite some time now. However, recently I've stumbled inte quite a problem. I've created a bunch of modules to handle all dynamic loading for me and things are good for simple programs. But now I want to load my dynamic loading modules dynamically (yes, it sounds weird) and that can't be done - not on linux anyways. The functions from the rts are ffi:ed into my program but when dynamically loading the module, these functions can't be found ("unknown symbol `lookupSymbol`") and neither can I load the HSrts.o package to make them visible due to duplicate functions ("I found a duplicate definition for symbol makeStableNamezh_fast"). How can I proceed? Can I pass some flag to the linker or such to force them to behave as I want? I only have this problem with linux (tested on Debian and Redhat) using ghc 6.2.1. On Solaris everything works just great (one doesn't even have to load any extra packages there) with ghc 6.0.1. /Hampus ps. my library can be found at http://www.dtek.chalmers.se/~d00ram/dynamic/ -- Homepage: http://www.dtek.chalmers.se/~d00ram E-mail: d00ram@dtek.chalmers.se "Det är aldrig försent att ge upp"

The functions from the rts are ffi:ed into my program but when dynamically loading the module, these functions can't be found ("unknown symbol `lookupSymbol`") and neither can I load the HSrts.o package to make them visible due to duplicate functions ("I found a duplicate definition for symbol makeStableNamezh_fast"). How can I proceed? Can I pass some flag to the linker or such to force them to behave as I want?
Does passing the flag RTLD_GLOBAL to dlopen help? (man dlopen for info about this flag) -- Alastair Reid

On Thu, Apr 29 2004, Alastair Reid wrote:
Does passing the flag RTLD_GLOBAL to dlopen help? (man dlopen for info about this flag)
No, since none of the objects involved are shared objects (I use neither dlopen or addDLL but the loadObj function). They are just compiled Haskell modules and the problem lies in the RTS symbols which for some reason can't be loaded dynamically (why it doesn't work when the base package etc. can be loaded is beyond me). However when loading shared objects your flag is the one to use. That works without flaw and is really a nicer way to load shared objects than the RTS function addDLL. /Hampus -- Homepage: http://www.dtek.chalmers.se/~d00ram E-mail: d00ram@dtek.chalmers.se "Det är aldrig försent att ge upp"

Hi,
I was playing with dynamically loaded modules and had the same problem.
It has nothing to do with shared objects. What you have to do is to
force
the main program (the one that loads the loadable modules) to explicitly
link all of the object files that the set {<main program>, <loadable
modules>}
depends on.
For example, if a module depends on symbols in
On Thu, Apr 29 2004, Alastair Reid wrote:
Does passing the flag RTLD_GLOBAL to dlopen help? (man dlopen for info about this flag)
No, since none of the objects involved are shared objects (I use neither dlopen or addDLL but the loadObj function). They are just compiled Haskell modules and the problem lies in the RTS symbols which for some reason can't be loaded dynamically (why it doesn't work when the base package etc. can be loaded is beyond me).
However when loading shared objects your flag is the one to use. That works without flaw and is really a nicer way to load shared objects than the RTS function addDLL.
/Hampus
-- Homepage: http://www.dtek.chalmers.se/~d00ram E-mail: d00ram@dtek.chalmers.se
"Det är aldrig försent att ge upp" _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On Thu, Apr 29 2004, Gregory Wright wrote:
It has nothing to do with shared objects.
No, it hasn't and I have never claimed that it is so.
the main program (the one that loads the loadable modules) to explicitly link all of the object files that the set {<main program>, <loadable modules>} depends on.
No. The problem isn't this and you need not do that in most cases as long as you dynamically load the libraries too (which I think you really should to allow truly dynamic loading not depending on which libraries you compiled in). The problem is the functions in the RTS that are ffi:ed into the dynamic loader. They are not "global" symbols on some platforms. The rts is linked into alls programs by default (so specifying it separatly is a no-op and waste of time). I have no problem what so ever with anything _but_ dynamically loading a module that requires functions from the RTS (i.e. loadObj, lookupSymbol etc.). However, I've now found the solution. All that was required was to give the flag -optl-export-dynamic to ghc, not -optl--export-dynamic, stupid mistake, but there it is... Thanks to all that tried to help me! /Hampus -- Homepage: http://www.dtek.chalmers.se/~d00ram E-mail: d00ram@dtek.chalmers.se "Det är aldrig försent att ge upp"
participants (3)
-
Alastair Reid
-
Gregory Wright
-
Hampus Ram