problem running ghc-api code in ghci 7.0.x

Daniel Gorín dgorin at dc.uba.ar
Thu Mar 3 05:05:22 CET 2011


Hi

I have code using the ghc-api that could be run in interactive mode prior to version 7 but now makes ghci crash with a linker error. Everything works fine if compiled before running. I don't know if this is a known issue or if I'm just using the api in the wrong way, but I thought that I might ask.

To illustrate the problem, consider this simple example:

t.hs:
> import qualified GHC
> import qualified GHC.Paths
> 
> main = GHC.runGhcT (Just GHC.Paths.libdir) $ do
>        -- begin initialize
>        df0 <- GHC.getSessionDynFlags
>        let df1 = df0{GHC.ghcMode    = GHC.CompManager,
>                      GHC.hscTarget  = GHC.HscInterpreted,
>                      GHC.ghcLink    = GHC.LinkInMemory,
>                      GHC.verbosity  = 0}
>        _ <- GHC.setSessionDynFlags df1 
>        -- begin reset
>        GHC.setContext [] []
>        GHC.setTargets []
>        _ <- GHC.load GHC.LoadAllTargets
>        return ()

I then see:

# ghci-6.12.1 -package ghc t.hs
GHCi, version 6.12.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
[...]
Loading package ffi-1.0 ... linking ... done.
[1 of 1] Compiling Main             ( dint.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Loading package ghc-paths-0.1.0.6 ... linking ... done.
*Main> 

# ghci-7.0.1 -package ghc t.hs
GHCi, version 7.0.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
[...]
Loading package ffi-1.0 ... linking ... done.
[1 of 1] Compiling Main             ( dint.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Loading package ghc-paths-0.1.0.8 ... linking ... done.


GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   ___stginit_ghczmprim_GHCziBool
whilst processing object file
   /Library/Frameworks/GHC.framework/Versions/7.0.1-i386/usr/lib/ghc-7.0.1/ghc-prim-0.2.0.0/libHSghc-prim-0.2.0.0.a
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.

# ghc-7.0.1 --make -package ghc t.hs
[1 of 1] Compiling Main             ( t.hs, t.o )
Linking t ..
# ./t
#

(that is, no error)


I'm using ghc for mac (intel 32 bits), downloaded in binary form from the ghc page.

Thanks,
Daniel


More information about the Glasgow-haskell-users mailing list