out of memory when running haddock
Simon Marlow
marlowsd at gmail.com
Tue Sep 30 04:28:34 EDT 2008
David Waern wrote:
> 2008/9/30 David Waern <david.waern at gmail.com>:
>> Here's the reduced program:
>
> Sorry, here's the correct version (it got messed up during copy-paste):
>
> (mkGhcModule is a complete no-op, it just creates a record out of some
> of the typechecking results)
>
> main :: IO ()
> main = handleTopExceptions $ do
> -- parse command-line flags and handle some of them initially
> args <- getArgs
> (flags, fileArgs) <- parseHaddockOpts args
> handleEasyFlags flags fileArgs
>
> when (null fileArgs) $ exitWith ExitSuccess
>
> libDir <- case getGhcLibDir flags of
> Just dir -> return dir
> Nothing ->
> #ifdef IN_GHC_TREE
> do m <- getExecDir
> case m of
> Nothing -> error "No GhcLibDir found"
> Just d -> return (d </> "..")
> #else
> return libdir -- from GHC.Paths
> #endif
>
> startGhc libDir (ghcFlags flags) $ \dynflags -> do
> -- load all argument files
> targets <- mapM (\f -> guessTarget f Nothing) fileArgs
> setTargets targets
>
> flag <- load LoadAllTargets
This is a problem. You're loading all the modules twice: once in the line
above, and once again when you typecheck each module below.
I noticed this myself when I looked at the Haddock code recently, and I
tried to fix it, but I discovered a problem with the new GHC API in the
process. In the old GHC API we could use checkAndLoadModule to load
individual modules in dependency order, but the new GHC API has changed
this - it almost provides the same functionality via
parseMOdule/typecheckModule/loadModule, but unfortunately it's missing the
ability to load a .hs-boot module, which we need for GHC. The old API
provided this because checkAndLoadModule took a ModSummary, which could be
a .hs-boot, whereas parseModule etc. take a Module.
Thomas - could you take a look, if you have time? We ought to fix this
before the 6.10.1 release if possible. It should be possible to load the
whole of GHC using just parseModule/typecheckModule/loadModule, with no
prior 'load'.
Oh, one other thing I tried is this: process modules using
parse/typecheck/loadModule, except when we reach a .hs-boot, when we do
'load (LoadUpTo m)' where m is the .hs-boot module. This ought to work,
but it failed with a strange error that looked like it was trying to load
things in the wrong order.
Cheers,
Simon
More information about the Cvs-ghc
mailing list