Re: problems with hs-plugins load-eval (possible bug)

The duplicate definition error appears when I compile Main.hs and execute it. But when I run it with runghc the behaviour is different. It works well:
runghc Main.hs 3
Any idea? is this a bug of hs-plugins? it is just something expected??
2008/12/6 Alberto G. Corona
I have a web server which load server extensions. these extensions eval-uate configuration files that contains code (user-editable workflow descriptions). The problem is that I need common definitions (inside imported modules) for the extensions and for the configuration files. This is not permitted by ha-plugins.
The minimal code example are the files below. main loads eval.hs , that evaluate a expression. The common definitions are in Include.hs. The error is:
*GHCi runtime linker: fatal error: I found a duplicate definition for symbol Include_sum1_srt whilst processing object file /home/magocoal/haskell/devel/votesWorkflow/src/unused/tests/Include.o
This could be caused by: * Loading two different object files which export the same symbol * Specifying the same object file twice on the GHCi command line * An incorrect `package.conf' entry, causing some object to be loaded twice. GHCi cannot safely continue in this situation. Exiting now. Sorry. *
** Do you kno how to solve the problem while maintaining the functionality?
-------Include.hs------- module Include where
sum [x,y]= x+y
------Main.hs----- module Main where
import Include import System.Plugins
main= do s <-loadExec "eval.o" "mainc" print s
loadExec:: String-> String->IO String loadExec file method = do
mv <- load file ["."] [] method case mv of LoadSuccess mod v -> v :: IO String LoadFailure msg -> return $ concat msg
------------Eval.hs--------
module Eval(mainc) where import System.IO.Unsafe import System.Eval.Haskell
mainc= do i <- unsafeEval_ "sum1 [1,2]" ["Include"] [] []["."] :: IO (Either [String] Int) return $ show i

Workaround: duplicate all the imported files and include a different copy
in each side.
Another workaround: package all the files imported in both sides.
Surprisingly, duplicate references do not appear when the imported files are
in a package.
PD: plugins adds 18 MBytes!! to the size of the executable. I suppose that
this is because the ghc library.
2008/12/9 Alberto G. Corona
The duplicate definition error appears when I compile Main.hs and execute it. But when I run it with runghc the behaviour is different. It works well:
runghc Main.hs 3
Any idea? is this a bug of hs-plugins? it is just something expected??
2008/12/6 Alberto G. Corona
I have a web server which load server extensions. these extensions eval-uate configuration files that contains code (user-editable workflow descriptions). The problem is that I need common definitions (inside imported modules) for the extensions and for the configuration files. This is not permitted by ha-plugins.
The minimal code example are the files below. main loads eval.hs , that evaluate a expression. The common definitions are in Include.hs. The error is:
*GHCi runtime linker: fatal error: I found a duplicate definition for symbol Include_sum1_srt whilst processing object file /home/magocoal/haskell/devel/votesWorkflow/src/unused/tests/Include.o
This could be caused by: * Loading two different object files which export the same symbol * Specifying the same object file twice on the GHCi command line * An incorrect `package.conf' entry, causing some object to be loaded twice. GHCi cannot safely continue in this situation. Exiting now. Sorry. *
** Do you kno how to solve the problem while maintaining the functionality?
-------Include.hs------- module Include where
sum [x,y]= x+y
------Main.hs----- module Main where
import Include import System.Plugins
main= do s <-loadExec "eval.o" "mainc" print s
loadExec:: String-> String->IO String loadExec file method = do
mv <- load file ["."] [] method case mv of LoadSuccess mod v -> v :: IO String LoadFailure msg -> return $ concat msg
------------Eval.hs--------
module Eval(mainc) where import System.IO.Unsafe import System.Eval.Haskell
mainc= do i <- unsafeEval_ "sum1 [1,2]" ["Include"] [] []["."] :: IO (Either [String] Int) return $ show i

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 2008/12/11 Alberto G. Corona :
Workaround: duplicate all the imported files and include a different copy in each side. Another workaround: package all the files imported in both sides. Surprisingly, duplicate references do not appear when the imported files are in a package. PD: plugins adds 18 MBytes!! to the size of the executable. I suppose that this is because the ghc library.
Yep. It's worth noting though: 1) this is true whether you go through hs-plugins or hint or raw GHC API. (Although Hint/raw API may be smaller - my Mueval binary is 13M total.) 2) You can shrink the binary a fair bit with 'strip' 3) Such binaries compress *very* well with utilities such as UPX. 4) This size may improve whenever dynamic libraries come and static linking is not the default. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklByaQACgkQvpDo5Pfl1oLlSwCfTxqZzT92ycKNjy1U3USbB53z p1QAnAg5TDO/bc38Uo0tvm7wh/jIVP+D =G6cI -----END PGP SIGNATURE-----
participants (2)
-
Alberto G. Corona
-
Gwern Branwen