Haskell runtime in shared library?

Hi, I'm trying to make a shared library containing the Haskell runtime, but no Haskell code per se. This shared library would then dynamically load other shared libraries containing conpiled Haskell code. Here is some pseudo code: In my_program: dlopen('my_haskell_runtime.so', RT_GLOBAL) ; hs_init(...) ; then later, in my_haskell_runtime.so: dlopen('my_haskell_module.so') ; __stginit_MyModule(); I've found some great information about FFI stuff here: http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-o... and here: http://blog.haskell.cz/pivnik/building-a-shared-library-in-haskell/ but I can't seem to find examples where the runtime is in a different shared object from the Haskell code/module. Is this possible to do something like this using GHC? If so, where can I find more information of how exactly to link my_haskell_runtime.so and my_haskell_module.so? Note: I'm fairy new to FFI (and Haskell in general), so it is possible that my terminology is lacking. Thanks a lot, Patrick -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada

Patrick LeBoutillier wrote:
I'm trying to make a shared library containing the Haskell runtime, but no Haskell code per se. This shared library would then dynamically load other shared libraries containing conpiled Haskell code. Here is some pseudo code:
In my_program: dlopen('my_haskell_runtime.so', RT_GLOBAL) ; hs_init(...) ;
then later, in my_haskell_runtime.so: dlopen('my_haskell_module.so') ; __stginit_MyModule();
I've found some great information about FFI stuff here: http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-o... and here: http://blog.haskell.cz/pivnik/building-a-shared-library-in-haskell/ but I can't seem to find examples where the runtime is in a different shared object from the Haskell code/module.
Is this possible to do something like this using GHC? If so, where can I find more information of how exactly to link my_haskell_runtime.so and my_haskell_module.so?
What you're trying to do is quite experimental and not fully supported right now. In order to put Haskell code in shared objects, you have to build the code in a special way (flags -dynamic -fPIC). The build system has some support for building shared libraries: try configuring with --enable-shared. If this works, you'll get all the libraries built two ways: static and shared. See this ticket for more info: http://hackage.haskell.org/trac/ghc/ticket/1876 Cheers, Simon
participants (2)
-
Patrick LeBoutillier
-
Simon Marlow