Dynamic/runtime loading with GHC
Hi all,
I've whipped up an example tarball of how to do "runtime loading"
(similar to dynamic loading, a.k.a. dlopen() or LoadLibrary()) in
GHC. You can find it here:
http://www.algorithm.com.au/wiki/hacking/haskell.ghc_runtime_loading
It's a little example stdin text filter program, that loads in .o
and .so "plugins" at runtime. New in version 1.1 is the ability
to load .so files as plugins :). I think that with a bit more
polish, we may even be able to rename this to a dynamic loader
one day.
Have fun!
--
#ozone/algorithm
On Sun, 22 Sep 2002 00:19:11 +1000
Andre Pang
It's a little example stdin text filter program, that loads in .o and .so "plugins" at runtime. New in version 1.1 is the ability to load .so files as plugins :). I think that with a bit more polish, we may even be able to rename this to a dynamic loader one day.
Indeed great. But I thought ghc code wasn;t supposed to work when inside a .so file!? What's going on? In fact it doesn't seem to be working entirely, I get an error on doing $ ./src/TextFilter ./plugins/ROT13.so < README [snip ROT13d README text] TextFilter: fatal error: scavenge_stack: weird activation record found on stack: 0 But still, it works mostly. Perhaps this success should motivate us to ask the ghc guys nicely what the remaining issues are since we seem quite close. As we all know using shared libraries would solve a some problems with the current dynamic linking scheme. In particular, dependancies. Dependancies of plugins on other plugins, external .so libraries and base packages. At the moment if a plugin depends on an external library you have to explicitly load the library before trying to load and resolve references in the plugin. The same goes for dependancies on other plugin modules and the base packages. If a plugin depends on a base package which you have not linked into the executable then that needs to be loaded before loading the plugin. This makes plugin management a bit of a pain. Duncan
participants (2)
-
Andre Pang -
Duncan Coutts