#1186: GHC as a library panic on loading second module
---------------------------------+------------------------------------------
    Reporter:  ArthurVanLeeuwen  |        Owner:  simonmar
        Type:  bug               |       Status:  new     
    Priority:  high              |    Milestone:  6.8     
   Component:  GHC API           |      Version:  6.6     
    Severity:  normal            |   Resolution:          
    Keywords:                    |   Difficulty:  Unknown 
          Os:  Unknown           |     Testcase:          
Architecture:  powerpc           |  
---------------------------------+------------------------------------------
Changes (by simonmar):

  * owner:  => simonmar

Comment:

 I can't repeat this with either 6.6, 6.6.1 or HEAD.  It always seems to
 complete successfully and exit for me.   Did I do something wrong?

 {{{
 > echo "main" | ghci-6.6 -package ghc ghclibtest.hs
    ___         ___ _
   / _ \ /\  /\/ __(_)
  / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
 / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
 \____/\/ /_/\____/|_|      Type :? for help.

 Loading package base ... linking ... done.
 Loading package template-haskell ... linking ... done.
 Loading package readline-1.0 ... linking ... done.
 Loading package unix-1.0 ... linking ... done.
 Loading package Cabal-1.1.6 ... linking ... done.
 Loading package regex-base-0.71 ... linking ... done.
 Loading package regex-posix-0.71 ... linking ... done.
 Loading package regex-compat-0.71 ... linking ... done.
 Loading package haskell98 ... linking ... done.
 Loading package ghc-6.6 ... linking ... done.
 [1 of 2] Compiling OtherModule      ( OtherModule.hs, interpreted )
 [2 of 2] Compiling GHCLibTest       ( ghclibtest.hs, interpreted )
 Ok, modules loaded: OtherModule, GHCLibTest.
 *GHCLibTest> [1 of 2] Compiling OtherModule      ( OtherModule.hs, nothing
 )
 [2 of 2] Compiling GHCLibTest       ( ghclibtest.hs, nothing )
 *GHCLibTest> Leaving GHCi.
 }}}

 Here's my ghclibtest.hs:

 {{{
 module GHCLibTest (setupsession,loadsession) where

 import GHC
 import PackageConfig
 import DynFlags
 import OtherModule

 main = setupsession >>= loadsession

 setupsession =
     do session <- newSession JustTypecheck (Just "/home/simonmar/fp/lib
 /x86_64-unknown-linux/ghc-6.6")
        f <- getSessionDynFlags session
        f' <- parseDynamicFlags f ["-package ghc", "-v1"]
        setSessionDynFlags session (fst f'){hscTarget = HscNothing}
        let preludeModule = mkModule (stringToPackageId "base")
 (mkModuleName "Prelude")
        setContext session [] [preludeModule]
        t <- guessTarget "ghclibtest.hs" Nothing
        addTarget session t
        return session

 loadsession session = load session LoadAllTargets

 other = 12
 }}}

 and to run it with HEAD, you'll need some more modifications:

 {{{
 module GHCLibTest (setupsession,loadsession) where

 import GHC
 import PackageConfig
 import DynFlags
 import OtherModule

 main = setupsession >>= loadsession

 setupsession =
     do session <- newSession (Just "/home/simonmar/builds/debugger")
        parseStaticFlags []
        f <- getSessionDynFlags session
        f' <- parseDynamicFlags f ["-package ghc", "-v1"]
        setSessionDynFlags session (fst f'){hscTarget = HscNothing}
        let preludeModule = mkModule (stringToPackageId "base")
 (mkModuleName "Prelude")
        setContext session [] [preludeModule]
        t <- guessTarget "ghclibtest.hs" Nothing
        addTarget session t
        return session

 loadsession session = load session LoadAllTargets

 other = 12
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1186>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to